Skip to content

Commit

Permalink
Fix false positive with Promise.any() in `no-array-prototype-extens…
Browse files Browse the repository at this point in the history
…ions` rule (#1761)

Fixes #1760
  • Loading branch information
bmish authored Jan 28, 2023
1 parent 184e2e5 commit 0891d4e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/rules/no-array-prototype-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ To reduce false positives, the rule ignores some common known-non-array classes/

- `Set.clear()`
- `Map.clear()`
- `Promise.reject()`
- `localStorage.clear()` / `sessionStorage.clear()`
- `Promise.any()` / `Promise.reject()`
- Lodash / jQuery
- etc

If you run into additional false positives, please file a bug or submit a PR to add it to the rule's hardcoded ignore list.
Expand Down
4 changes: 4 additions & 0 deletions lib/rules/no-array-prototype-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ const KNOWN_NON_ARRAY_FUNCTION_CALLS = new Set([
'Ember.RSVP.reject()',
'Ember.RSVP.Promise.reject()',

// Promise.any()
'window.Promise.any()',
'Promise.any()',

// *storage.clear()
'window.localStorage.clear()',
'window.sessionStorage.clear()',
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/no-array-prototype-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ ruleTester.run('no-array-prototype-extensions', rule, {
'reject();',
'this.reject();',

// Promise.any()
'Promise.any();',
'window.Promise.any();',

// Global non-array class (RSVP.reject)
'RSVP.reject();',
'RSVP.reject("some reason");',
Expand Down

0 comments on commit 0891d4e

Please sign in to comment.