diff --git a/rules/no-useless-undefined.js b/rules/no-useless-undefined.js index 8180670985..f6b8194873 100644 --- a/rules/no-useless-undefined.js +++ b/rules/no-useless-undefined.js @@ -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 => { diff --git a/test/no-useless-undefined.mjs b/test/no-useless-undefined.mjs index 1b14bc794f..9eeca640b7 100644 --- a/test/no-useless-undefined.mjs +++ b/test/no-useless-undefined.mjs @@ -51,6 +51,8 @@ test({ 'array.push(undefined);', 'array.unshift(foo, undefined);', 'array.unshift(undefined);', + 'createContext(undefined);', + 'React.createContext(undefined);', // `checkArguments: false` { @@ -276,6 +278,8 @@ test.typescript({ 'const foo = (): string => undefined;', 'const foo = function (): undefined {return undefined}', 'export function foo(): undefined {return undefined}', + 'createContext(undefined);', + 'React.createContext(undefined);', outdent` const object = { method(): undefined { @@ -332,6 +336,8 @@ test.typescript({ } } `, + 'createContext(undefined);', + 'React.createContext(undefined);', ], invalid: [ {