Skip to content
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

Open
wants to merge 5 commits into
base: v3
Choose a base branch
from

Conversation

serikovlearning
Copy link

…ule (#845)

Copy link

stackblitz bot commented Oct 4, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

vercel bot commented Oct 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
reatom ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 7, 2024 5:24pm

Comment on lines 49 to 54
ImportDeclaration(node: estree.ImportDeclaration) {
lastImport = node
if (isImportICareAbout(node)) {
hasImport = true
}
},
Copy link
Collaborator

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

Suggested change
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
},

Copy link
Author

@serikovlearning serikovlearning Oct 10, 2024

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)
    
    ````

Copy link
Collaborator

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)$/]

Copy link
Author

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?

@serikovlearning serikovlearning changed the title feat(eslint-plugin): complete wrap-schedule-instead-of-ctx-schedule-r… feat(eslint-plugin): wrap-schedule-instead-of-ctx-schedule-rule Oct 10, 2024
@serikovlearning serikovlearning marked this pull request as ready for review October 10, 2024 17:48
Copy link
Owner

@artalar artalar left a 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"

@artalar
Copy link
Owner

artalar commented Oct 31, 2024

I mean, wrap-schedule-instead-of-ctx-schedule-rule.ts -> schedule-import-rule.ts and all related export and import variables names.

@serikovlearning
Copy link
Author

I mean, wrap-schedule-instead-of-ctx-schedule-rule.ts -> schedule-import-rule.ts and all related export and import variables names.

done

@serikovlearning serikovlearning changed the title feat(eslint-plugin): wrap-schedule-instead-of-ctx-schedule-rule feat(eslint-plugin): schedule-import-rule Nov 4, 2024
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.

3 participants