Skip to content

Commit

Permalink
feat(eslint-plugin): added more test cases for prefer-nullish-coalesc…
Browse files Browse the repository at this point in the history
…ing rule
  • Loading branch information
jguddas committed May 16, 2022
1 parent 6394ec3 commit da7c7c6
Showing 1 changed file with 17 additions and 0 deletions.
Expand Up @@ -77,6 +77,7 @@ x ?? 'foo';
},

...[
'x !== undefined && x !== null ? "foo" : "bar";',
'x !== null && x !== undefined && x !== 5 ? x : y',
'x === null || x === undefined || x === 5 ? x : y',
'x === undefined && x !== null ? x : y;',
Expand All @@ -95,13 +96,29 @@ x ?? 'foo';
'null != x ? y : x;',
'undefined != x ? y : x;',
`
declare const x: string | null;
x === undefined ? x : y;
`,
`
declare const x: string | undefined | null;
x !== undefined ? x : y;
`,
`
declare const x: string | undefined | null;
x !== null ? x : y;
`,
`
declare const x: string | null | any;
x === null ? x : y;
`,
`
declare const x: string | null | unknown;
x === null ? x : y;
`,
`
declare const x: string | undefined;
x === null ? x : y;
`,
].map(code => ({
code: code.trim(),
options: [{ ignoreTernaryTests: false }] as const,
Expand Down

0 comments on commit da7c7c6

Please sign in to comment.