Skip to content
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

Fix false positives with RSVP.Promise.reject() in no-array-prototype-extensions rule #1546

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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