Skip to content

new ESLint Rule for named useEffect callback#6473

Merged
witoszekdev merged 3 commits into
mainfrom
lkostrowski/named-effects-rule
Mar 26, 2026
Merged

new ESLint Rule for named useEffect callback#6473
witoszekdev merged 3 commits into
mainfrom
lkostrowski/named-effects-rule

Conversation

@lkostrowski
Copy link
Copy Markdown
Member

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)

@lkostrowski lkostrowski requested a review from a team as a code owner March 26, 2026 11:41
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 26, 2026

⚠️ No Changeset found

Latest commit: 08a1de8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@lkostrowski lkostrowski added the skip changeset Use if your changes doesn't need entry in changelog label Mar 26, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 43.55%. Comparing base (7bf722f) to head (08a1de8).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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-effects rule and enable it as a warning in eslint.config.mjs.
  • Convert existing local rules/tests to .mjs ESM imports/exports and update RuleTester usage.
  • Add test:lint-rules script and chain it into pnpm 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 CallExpression listener is declared as (codePath, node) => { ... }, but ESLint passes only the AST node to this selector. As written, node will be undefined and the report uses node instead of the actual CallExpression node. Update the listener signature to take a single node parameter (and use that for .callee / .arguments and context.report).

Comment thread lint/rules/named-effects.test.mjs
Comment thread package.json
Comment thread lint/rules/named-effects.mjs Outdated
Comment thread lint/rules/named-effects.mjs Outdated
@github-actions
Copy link
Copy Markdown
Contributor

Differences Found

✅ No packages or licenses were added.

Summary

Expand
License Name Package Count Packages
0BSD 1
Packages
  • tslib
CC0-1.0 1
Packages
  • type-fest
MIT/X11 1
Packages
  • nub
MPL-1.1 1
Packages
  • harmony-reflect
MPL-2.0 1
Packages
  • dompurify
Public Domain 1
Packages
  • jsonify
Python-2.0 1
Packages
  • argparse
WTFPL 1
Packages
  • utf8-byte-length
CC-BY-4.0 2
Packages
  • @saleor/macaw-ui
  • caniuse-lite
SEE LICENSE IN LICENSE 2
Packages
  • posthog-js
  • spawndamnit
BlueOak-1.0.0 5
Packages
  • glob
  • lru-cache
  • minimatch
  • minipass
  • path-scurry
<<missing>> 11
Packages
  • @sentry/cli
  • @sentry/cli-darwin
  • @sentry/cli-linux-arm
  • @sentry/cli-linux-arm64
  • @sentry/cli-linux-i686
  • @sentry/cli-linux-x64
  • @sentry/cli-win32-arm64
  • @sentry/cli-win32-i686
  • @sentry/cli-win32-x64
  • busboy
  • streamsearch
BSD-2-Clause 23
Packages
  • browser-process-hrtime
  • css-select
  • css-what
  • domelementtype
  • domhandler
  • domutils
  • dotenv
  • dotenv-expand
  • entities
  • escodegen
  • eslint-scope
  • espree
  • esprima
  • esrecurse
  • estraverse
  • esutils
  • nth-check
  • regjsparser
  • stringify-object
  • terser
  • And 3 more...
ISC 48
Packages
  • @istanbuljs/load-nyc-config
  • anymatch
  • boolbase
  • cli-width
  • cliui
  • electron-to-chromium
  • fastq
  • flatted
  • fs.realpath
  • get-caller-file
  • get-own-enumerable-property-symbols
  • glob
  • glob-parent
  • graceful-fs
  • inflight
  • inherits
  • ini
  • isexe
  • knip
  • lru-cache
  • And 28 more...
BSD-3-Clause 53
Packages
  • @protobufjs/aspromise
  • @protobufjs/base64
  • @protobufjs/codegen
  • @protobufjs/eventemitter
  • @protobufjs/fetch
  • @protobufjs/float
  • @protobufjs/inquire
  • @protobufjs/path
  • @protobufjs/pool
  • @protobufjs/utf8
  • @saleor/app-sdk
  • @sentry/cli
  • @sentry/cli-darwin
  • @sentry/cli-linux-arm
  • @sentry/cli-linux-arm64
  • @sentry/cli-linux-i686
  • @sentry/cli-linux-x64
  • @sentry/cli-win32-i686
  • @sentry/cli-win32-x64
  • @sinonjs/commons
  • And 33 more...
Apache-2.0 64
Packages
  • @editorjs/editorjs
  • @eslint/config-array
  • @eslint/config-helpers
  • @eslint/core
  • @eslint/object-schema
  • @eslint/plugin-kit
  • @humanfs/core
  • @humanfs/node
  • @humanwhocodes/module-importer
  • @humanwhocodes/retry
  • @opentelemetry/api
  • @opentelemetry/api-logs
  • @opentelemetry/core
  • @opentelemetry/exporter-logs-otlp-http
  • @opentelemetry/otlp-exporter-base
  • @opentelemetry/otlp-transformer
  • @opentelemetry/resources
  • @opentelemetry/sdk-logs
  • @opentelemetry/sdk-metrics
  • @opentelemetry/sdk-trace-base
  • And 44 more...
MIT 1324
Packages
  • @adobe/css-tools
  • @apollo/client
  • @ardatan/relay-compiler
  • @ardatan/sync-fetch
  • @babel/code-frame
  • @babel/compat-data
  • @babel/core
  • @babel/generator
  • @babel/helper-annotate-as-pure
  • @babel/helper-compilation-targets
  • @babel/helper-create-class-features-plugin
  • @babel/helper-globals
  • @babel/helper-member-expression-to-functions
  • @babel/helper-module-imports
  • @babel/helper-module-transforms
  • @babel/helper-optimise-call-expression
  • @babel/helper-plugin-utils
  • @babel/helper-replace-supers
  • @babel/helper-skip-transparent-expression-wrappers
  • @babel/helper-string-parser
  • And 1304 more...

@lkostrowski lkostrowski changed the title new eslint rule for named eslint callback new ESLint Rule for named useEffect callback Mar 26, 2026
Copy link
Copy Markdown
Contributor

@witoszekdev witoszekdev left a comment

Choose a reason for hiding this comment

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

great stuff 🚀

@witoszekdev witoszekdev merged commit 6cb84c0 into main Mar 26, 2026
20 of 22 checks passed
@witoszekdev witoszekdev deleted the lkostrowski/named-effects-rule branch March 26, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changeset Use if your changes doesn't need entry in changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants