You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rules/no-unused-array-method-return.js:251 — getVariableValue returns definition.node.init unconditionally. When a declarator has no initializer (uninitialized let, for…of, for…in, for (let x; …)), init is null. resolveReceiver then recurses with null and throws TypeError: Cannot read properties of null (reading 'type') at line 171.
Reproduced via npx ava test/no-unused-array-method-return.js after dropping these inputs into the existing test file:
'let array; array.map(fn);'// CRASH'for (const x of arr) x.map(fn);'// CRASH'for (let x of arr) x.map(fn);'// CRASH'for (var x of arr) x.map(fn);'// CRASH'for (const x in obj) x.map(fn);'// CRASH'for (let x; x.length;) x.map(fn);'// CRASH
Suggested fix: add && definition.node.init to the condition at lines 244–250, returning uncertainValue for these cases (matches the documented "for…of bindings unsupported" intent). Worth adding at least one for…of and one bare let x; to the test file to prevent regression.
Code quality
L9–40 — methodNames is only used to build methods; inline as const methods = new Set([...]);.
L224–238 and L289–304 — ~30 lines of inline boundary commentary largely repeat what the docs already explain. Trimming would match the terser style of nearby rules.
Mix of const x = (…) => and function x(…) declarations in the same file is inconsistent.
Heuristic gaps
.slice / .at / .includes / .indexOf / .concat / .lastIndexOf exist on strings; unresolved receivers will false-positive. Acknowledged in the docs, but worth a final risk check before promoting beyond unopinionated.
Statement-level SequenceExpression (e.g. sideEffect(), arr.map(fn);) is silently skipped — listed as intentional but a real false negative.
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
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.
Fixes #741