feat(css-plugins-to-native-css): better ast-grep usage - #11
feat(css-plugins-to-native-css): better ast-grep usage#11AugustinMauroy wants to merge 2 commits into
css-plugins-to-native-css): better ast-grep usage#11Conversation
🦋 Changeset detectedLatest commit: d02519d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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
left a comment
There was a problem hiding this comment.
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() ===` |
There was a problem hiding this comment.
| 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; |
There was a problem hiding this comment.
| if (!manifest || !manifest.is("object")) return null; | |
| if (!(manifest?.is("object"))) return null; |
Does this work?
|
|
||
| editor.finalizeRemovals(); | ||
|
|
||
| if (!editor.hasEdits) return null; | ||
|
|
| const arg = args[0]; | ||
| if (!arg.is("string")) return false; | ||
|
|
||
| return arg.find({ rule: { kind: "string_fragment" } })?.text() === PLUGIN_MODULE; |
There was a problem hiding this comment.
We have { rule: { kind: "string_fragment" } }) eight times, can that be unified?
There was a problem hiding this comment.
we can create a searchStringFrangment(node) but I don't think it's better
| // 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 |
There was a problem hiding this comment.
Can you reword this comment, I'm afraid I don't follow
There was a problem hiding this comment.
I add ?? "" because in typescript context find() string_fragment can be null so ?.text() can be undefined.
But this check is reduant since string node always have string_fragment
| ); | ||
|
|
||
| if (!publicPath || !publicPath.is("string")) return false; | ||
|
|
There was a problem hiding this comment.
Can you revert the unrelated newline changes?
| } | ||
| if (this.pluginNames.size > 0) return true; | ||
| return findConfigObjectFor(usePair) !== null; |
Description
is()instead ofkind() ===unquoteto use nodestring_fragmentgitkeep