new ESLint Rule for named useEffect callback#6473
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6473 +/- ##
=======================================
Coverage 43.55% 43.55%
=======================================
Files 2578 2578
Lines 44929 44929
Branches 10522 10522
=======================================
Hits 19570 19570
Misses 25319 25319
Partials 40 40 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a new local ESLint rule to encourage named useEffect callbacks (per linked article), migrates existing local rules/tests to ESM, and introduces a script intended to ensure these rule tests run as part of testing.
Changes:
- Add
local-rules/named-effectsrule and enable it as a warning ineslint.config.mjs. - Convert existing local rules/tests to
.mjsESM imports/exports and updateRuleTesterusage. - Add
test:lint-rulesscript and chain it intopnpm test.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Chains lint-rule tests into the test script and adds test:lint-rules. |
| lint/rules/no-deprecated-icons.mjs | Switches local rule export from CJS to ESM default export. |
| lint/rules/named-styles.test.mjs | Migrates test to ESM + updates expectations to messageId and fixed output. |
| lint/rules/named-styles.mjs | Switches local rule export from CJS to ESM default export. |
| lint/rules/named-effects.test.mjs | Adds RuleTester coverage for the new named-effects rule. |
| lint/rules/named-effects.mjs | Introduces the new ESLint rule implementation. |
| lint/rules/index.mjs | Registers the new rule and updates imports to .mjs. |
| eslint.config.mjs | Enables the new local rule under the local-rules plugin. |
Comments suppressed due to low confidence (1)
lint/rules/named-styles.mjs:5
- The
CallExpressionlistener is declared as(codePath, node) => { ... }, but ESLint passes only the AST node to this selector. As written,nodewill beundefinedand the report usesnodeinstead of the actualCallExpressionnode. Update the listener signature to take a singlenodeparameter (and use that for.callee/.argumentsandcontext.report).
Differences Found✅ No packages or licenses were added. SummaryExpand
|
Based on this article https://neciudan.dev/name-your-effects
Let's follow this pattern. I added custom rule + changed old rules to .mjs + added script that will run tests (it was not run in CI)