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

no-useless-undefined: Ignore Array#includes() and Set#has() #1951

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 15 additions & 7 deletions rules/no-useless-undefined.js
Expand Up @@ -69,18 +69,26 @@ const shouldIgnore = node => {
}

return compareFunctionNames.has(name)
// https://vuejs.org/api/reactivity-core.html#ref
|| name === 'ref'
// `set.add(undefined)`
|| name === 'add'
// `map.set(foo, undefined)`
|| name === 'set'
// `array.push(undefined)`
|| name === 'push'
// `array.unshift(undefined)`
|| name === 'unshift'
// `array.includes(undefined)`
|| name === 'includes'

// `set.add(undefined)`
|| name === 'add'
// `set.has(undefined)`
|| name === 'has'

// `map.set(foo, undefined)`
|| name === 'set'

// `React.createContext(undefined)`
|| name === 'createContext';
|| name === 'createContext'

// https://vuejs.org/api/reactivity-core.html#ref
|| name === 'ref';
};

const getFunction = scope => {
Expand Down
2 changes: 2 additions & 0 deletions test/no-useless-undefined.mjs
Expand Up @@ -53,6 +53,8 @@ test({
'array.unshift(undefined);',
'createContext(undefined);',
'React.createContext(undefined);',
'array.includes(undefined)',
'set.has(undefined)',

// `Function#bind()`
'foo.bind(bar, undefined)',
Expand Down