-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(eslint-plugin): schedule-import-rule #930
base: v3
Are you sure you want to change the base?
Conversation
Run & review this pull request in StackBlitz Codeflow. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
packages/eslint-plugin/src/rules/wrap-schedule-instead-of-ctx-schedule-rule.ts
Outdated
Show resolved
Hide resolved
ImportDeclaration(node: estree.ImportDeclaration) { | ||
lastImport = node | ||
if (isImportICareAbout(node)) { | ||
hasImport = true | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isImportICareAbout
could have been an esquery selector. it should also handle imports from the core package as well as from framework
ImportDeclaration(node: estree.ImportDeclaration) { | |
lastImport = node | |
if (isImportICareAbout(node)) { | |
hasImport = true | |
} | |
}, | |
ImportDeclaration(node) { | |
lastImport = node | |
}, | |
"ImportSpecifier[source.value=/^@reatom\//][imported.name=/^(wrap|schedule)$]"(node: estree.ImportDeclaration) { | |
hasImport = true | |
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried by that not works for me.
I have no idea what's wrong and chatGpt don't help me.
Error trace:
Throw new SyntaxError(`Syntax error in selector "${rawSelector}" at position ${err.location.start.offset}: ${err.message}`);
^
SyntaxError: Syntax error in selector "ImportSpecifier[source.value=/^@reatom//][imported.name=/^(wrap|schedule)$]" at position 39: Expected " ", "]", or [imsu] but "/" found.
Occurred while linting <input>
at tryParseSelector (/*/reatom/node_modules/eslint/lib/linter/node-event-generator.js:196:19)
at parseSelector (/*/reatom/node_modules/eslint/lib/linter/node-event-generator.js:214:28)
at /*/reatom/node_modules/eslint/lib/linter/node-event-generator.js:265:30
at Array.forEach (<anonymous>)
at new NodeEventGenerator (/*/reatom/node_modules/eslint/lib/linter/node-event-generator.js:264:30)
at runRules (/*/reatom/node_modules/eslint/lib/linter/linter.js:1077:32)
at Linter._verifyWithoutProcessors (//reatom/node_modules/eslint/lib/linter/linter.js:1330:31)
at Linter.verify (/*/reatom/node_modules/eslint/lib/linter/linter.js:1428:57)
at runRuleForItem (/*/reatom/node_modules/eslint/lib/rule-tester/rule-tester.js:689:35)
at testValidTemplate (/*/reatom/node_modules/eslint/lib/rule-tester/rule-tester.js:749:28)
````
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this selector should work: ImportDeclaration[source.value=/^@reatom\x2f/] > ImportSpecifier[imported.name=/^(wrap|schedule)$/]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortuanlly, no.
Is that necessary to use selector instead of if statement?
I don't really good at eslint plugins. I don't undestand perfomance difference.
I think my writed code is more flexible and expandable in a way to add new ImportSpecifiers just into array. Espcially if some juniors come to help with plugins.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, rename all related things to "schedule import"
I mean, |
done |
…ule (#845)