Skip to content

Commit

Permalink
Allow React.createContext(undefined) in no-useless-undefined (#1688)
Browse files Browse the repository at this point in the history
  • Loading branch information
kachkaev committed Jan 11, 2022
1 parent 3c00345 commit 40bc603
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rules/no-useless-undefined.js
Expand Up @@ -78,7 +78,9 @@ const shouldIgnore = node => {
// `array.push(undefined)`
|| name === 'push'
// `array.unshift(undefined)`
|| name === 'unshift';
|| name === 'unshift'
// `React.createContext(undefined)`
|| name === 'createContext';
};

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

// `checkArguments: false`
{
Expand Down Expand Up @@ -276,6 +278,8 @@ test.typescript({
'const foo = (): string => undefined;',
'const foo = function (): undefined {return undefined}',
'export function foo(): undefined {return undefined}',
'createContext<T>(undefined);',
'React.createContext<T>(undefined);',
outdent`
const object = {
method(): undefined {
Expand Down Expand Up @@ -332,6 +336,8 @@ test.typescript({
}
}
`,
'createContext<T>(undefined);',
'React.createContext<T>(undefined);',
],
invalid: [
{
Expand Down

0 comments on commit 40bc603

Please sign in to comment.