Uh oh!
There was an error while loading. Please reload this page.
Add custom eslint rule 'no-array-mutating-method-expressions' - #59526
Conversation
Ryan Cavanaugh (RyanCavanaugh)
commented
Aug 5, 2024
We could instead add an earlier overload via declaration merging to return |
Jake Bailey (jakebailey)
commented
Aug 5, 2024
I'm not totally sure how we'd add an overload before the lib.d.ts, but I guess it must be possible because ts-reset or whatever can do it? But, that wouldn't allow us to ignore the calls that happen after we're sure the array has been cloned (which is what this PR does); we don't have that many calls to sort but most of them are actually ignored by this rule. |
Ryan Cavanaugh (RyanCavanaugh)
commented
Aug 5, 2024
Overloads from declaration merging to in "before" the overloads they merge with |
Jake Bailey (jakebailey)
commented
Aug 6, 2024
Planning on going through the list of mutating methods from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#copying_methods_and_mutating_methods and adding them here too; same kind of bug. |
Uh oh!
There was an error while loading. Please reload this page.
5ed0892 to
eb5e5abCompare| if (!logs) return; | ||
| logger.log(title); | ||
| logs.sort((a, b) => compareStringsCaseSensitive(a[0], b[0])) | ||
| toSorted(logs, (a, b) => compareStringsCaseSensitive(a[0], b[0])) |
There was a problem hiding this comment.
This is a bug.
| const refactors = this.getApplicableRefactorsAtSelection("invoked", kind, preferences); | ||
| const availableKinds = ts.flatMap(refactors, refactor => refactor.actions).map(action => action.kind); | ||
| assert.deepEqual(availableKinds.sort(), expected.sort(), `Expected kinds to be equal`); | ||
| assert.deepEqual(availableKinds.slice().sort(), expected.slice().sort(), `Expected kinds to be equal`); |
There was a problem hiding this comment.
This is a bug, more or less.
| assert(result.targetRange === undefined, "failure expected"); | ||
| const sortedErrors = result.errors.map(e => e.messageText as string).sort(); | ||
| assert.deepEqual(sortedErrors, expectedErrors.sort(), "unexpected errors"); | ||
| assert.deepEqual(sortedErrors, expectedErrors.slice().sort(), "unexpected errors"); |
There was a problem hiding this comment.
This is a bug.
Motivated by the bug found in #59523.
Needs tests.