feat!: add no-reduce-accumulator-copy rule - #62
Merged
Conversation
davidding
force-pushed
the
feature/add-no-reduce-accumulator-copy-rule
branch
from
August 18, 2026 12:36
e129340 to
14d1c89
Compare
davidding
marked this pull request as ready for review
August 18, 2026 13:19
davidding
requested review from
TyStelmach,
alex-117,
anngo-hs,
cfrisoli,
craigayre,
darkmavis1980,
david-mooney,
denisolvr,
mrndhlovu,
nhorilopchan and
swatinigam
August 18, 2026 13:19
…ed plugin config blocks
darkmavis1980
previously approved these changes
Aug 19, 2026
denisolvr
previously approved these changes
Aug 19, 2026
Contributor
|
Also don't forget to set the version properly to be a minor |
Contributor
Author
@darkmavis1980 Version numbers are automatically handled by the release workflow, based on conventional commit messages - #52 |
davidding
dismissed stale reviews from denisolvr and darkmavis1980
via
August 20, 2026 11:28
ede91b4
darkmavis1980
approved these changes
Aug 20, 2026
denisolvr
reviewed
Aug 24, 2026
denisolvr
left a comment
There was a problem hiding this comment.
question: Is the -copy.js files on purpose named as copy?
Contributor
Author
@denisolvr - Yes, the new rule is |
davidding
enabled auto-merge (squash)
August 24, 2026 09:01
denisolvr
approved these changes
Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose / Goal
Adds an ESLint rule that flags O(n²) accumulator copies inside
reduce/reduceRightcallbacks — object spreads ({ ...acc },[...acc]), andacc.concat()— and directs developers toward afor...ofloop with mutation or a purpose-built method (e.g.flatMap,Object.groupBy).Summary of Changes 📋
plugins/hs-web-team/rules/no-reduce-accumulator-copy.js— ESM named export, implemented usingcontext.sourceCode.getScope(node)(ESLint v9 flat config API)plugins/hs-web-team/index.js— shared plugin registry; exposeshsWebTeamPlugin.configs.recommended(following thetypescript-eslint/eslint-plugin-reactpattern) so bothindex.jsandbrowser.jsspread a single config object rather than duplicating plugin registration. Rules are co-located underplugins/hs-web-team/rules/following the same layout as standalone ESLint plugin packages.eslint.config.js— repo-local config that extends the shared Node config; adds Cypress globals forcypress/**sono-undefdoes not false-positive onCypress/cyeslint.config.jsfromcommonIgnoresin both configs — config files should meet the same lint standards as any other filelintscript toeslint .(waseslint -c ./index.js *.js) so all subdirectories are covered without an explicit include listtests/plugins/hs-web-team/no-reduce-accumulator-copy.test.js— 10 test cases vianode:test+ ESLintRuleTester, covering object spread, array spread,concat,reduceRight, in-place mutation (valid), and non-accumulator spreads (valid)npm testtonode --testand add a test step to the PR workflowfilesfield topackage.json— scopes the published tarball to only the files consumers need; excludes tests,.github/,.githooks/,eslint.config.js, andCLAUDE.mdexamples/custom-rules.md— documents the bundledhs-web-teamplugin rules with bad/good code examples and remediation guidanceREADME.md— add "Custom Rules" section and index entry linking to the new examples fileScreenshot(s) or GIF(s) 📸
N/A - No UI changes
Production Checklist ✅
Relevant Links 🔗
Coding Standards Doc ⌨️