-
Notifications
You must be signed in to change notification settings - Fork 17
SHARD-2733 updated linting setup and rules. Added rule for unused pure functions #551
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
base: dev
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
] | ||
|
||
const options = context.options[0] || {} | ||
const pureMethods = [...defaultPureMethods, ...(options.pureMethods || [])] |
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.
Suggestion: The pureMethods
array may contain duplicate method names, especially since some methods like 'slice', 'substr', and 'substring' appear multiple times in defaultPureMethods
. This can cause unnecessary repeated checks and potential confusion. Remove duplicates from the pureMethods
array to ensure each method is only checked once. [general, importance: 6]
const pureMethods = [...defaultPureMethods, ...(options.pureMethods || [])] | |
const pureMethods = Array.from(new Set([...defaultPureMethods, ...(options.pureMethods || [])])) |
'assign', | ||
'keys', | ||
'values', | ||
'entries', | ||
'freeze', | ||
'seal', | ||
'getOwnPropertyNames', | ||
'getOwnPropertyDescriptors', | ||
'sign', | ||
] |
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.
Suggestion: The defaultPureMethods
array includes 'assign', which is not a pure function (Object.assign mutates the first argument). Remove 'assign' to avoid false positives where mutating methods are flagged as pure. [possible issue, importance: 9]
'assign', | |
'keys', | |
'values', | |
'entries', | |
'freeze', | |
'seal', | |
'getOwnPropertyNames', | |
'getOwnPropertyDescriptors', | |
'sign', | |
] | |
'keys', | |
'values', | |
'entries', | |
'freeze', | |
'seal', | |
'getOwnPropertyNames', | |
'getOwnPropertyDescriptors', | |
'sign', | |
] |
PR Type
Enhancement
Description
Migrated ESLint configuration to flat config with
eslint.config.mjs
Added custom ESLint plugin for unused pure function calls
Updated and expanded ESLint and related dependencies
Improved lint script and dependency versions in
package.json
Changes walkthrough 📝
eslint.config.mjs
Add flat ESLint config with custom rules and ignores
eslint.config.mjs
.eslintrc.json
Remove legacy ESLint configuration file
.eslintrc.json
index.js
Add custom ESLint plugin entry for pure functions
eslint-plugin-pure-functions/index.js
no-unused-pure-calls.js
Add rule to detect unused pure function calls
eslint-plugin-pure-functions/rules/no-unused-pure-calls.js
package.json
Update ESLint dependencies and scripts for new config
package.json