From b32e2f160e835ffe92ee615fbfc42c9a063bc8d8 Mon Sep 17 00:00:00 2001 From: Alexander Kachkaev Date: Mon, 10 Jan 2022 21:32:52 +0000 Subject: [PATCH] Allow `React.createContext(undefined)` --- rules/no-useless-undefined.js | 4 +++- test/no-useless-undefined.mjs | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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: [ {