Skip to content

feat(css-plugins-to-native-css): better ast-grep usage - #11

Open
AugustinMauroy wants to merge 2 commits into
webpack:mainfrom
AugustinMauroy:clean
Open

feat(css-plugins-to-native-css): better ast-grep usage#11
AugustinMauroy wants to merge 2 commits into
webpack:mainfrom
AugustinMauroy:clean

Conversation

@AugustinMauroy

@AugustinMauroy AugustinMauroy commented Aug 13, 2026

Copy link
Copy Markdown

Description

  • use is() instead of kind() ===
  • remove usage of unquote to use node string_fragment
  • remove useless gitkeep

@changeset-bot

changeset-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d02519d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@webpack/css-plugins-to-native-css Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@avivkeller avivkeller left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't bump the version, changesets will handle that

"@webpack/css-plugins-to-native-css": patch
---

remove `unquote` and use `is` methode instead of `kind() ===`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
remove `unquote` and use `is` methode instead of `kind() ===`
Updates internal comparisons of `ast-grep` to use built-in operators

const manifest = namedChildren(rootNode)[0];
if (!manifest || manifest.kind() !== "object") return null;

if (!manifest || !manifest.is("object")) return null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!manifest || !manifest.is("object")) return null;
if (!(manifest?.is("object"))) return null;

Does this work?

Comment on lines +28 to +32

editor.finalizeRemovals();

if (!editor.hasEdits) return null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated

const arg = args[0];
if (!arg.is("string")) return false;

return arg.find({ rule: { kind: "string_fragment" } })?.text() === PLUGIN_MODULE;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have { rule: { kind: "string_fragment" } }) eight times, can that be unified?

Comment on lines +434 to +435
// in theroy it's impossible to have "string" wihhout a string_fragment
// but typescript doesn't know that, so we need to check for null/undefined

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you reword this comment, I'm afraid I don't follow

);

if (!publicPath || !publicPath.is("string")) return false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you revert the unrelated newline changes?

Comment on lines 671 to 673
}
if (this.pluginNames.size > 0) return true;
return findConfigObjectFor(usePair) !== null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this changing behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants