Skip to content

Commit

Permalink
Merge pull request #1546 from bmish/no-array-prototype-extensions-rsv…
Browse files Browse the repository at this point in the history
…p-reject

Fix false positives with `RSVP.Promise.reject()` in `no-array-prototype-extensions` rule
  • Loading branch information
lin-ll committed Jul 29, 2022
2 parents fd83412 + 1a8806c commit 7d9fa8e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/rules/no-array-prototype-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ const KNOWN_NON_ARRAY_FUNCTION_CALLS = new Set([

// RSVP.reject
'RSVP.reject',
'RSVP.Promise.reject',
'Ember.RSVP.reject',
'Ember.RSVP.Promise.reject',

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

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

// Global non-array class (*storage.clear)
'window.localStorage.clear();',
'window.sessionStorage.clear();',
'localStorage.clear();',
'sessionStorage.clear();',
'sessionStorage?.clear();',
'clear();',
'this.clear();',

// Global non-array class (location.replace)
'window.document.location.replace(url)',
Expand Down

0 comments on commit 7d9fa8e

Please sign in to comment.