Skip to content

Commit

Permalink
add some straightforward tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkwaiblinger committed Feb 23, 2024
1 parent 7fd8285 commit 9d1b79a
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions packages/eslint-plugin/tests/rules/prefer-find.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,52 @@ arr.find(f, thisArg);
},
{
code: `
(Math.random() < 0.5
? [1, 2, 3].filter(x => false)
: [1, 2, 3].filter(x => true))[0];
`,
errors: [
{
line: 2,
messageId: 'preferFind',
suggestions: [
{
messageId: 'preferFindSuggestion',
output: `
(Math.random() < 0.5
? [1, 2, 3].find(x => false)
: [1, 2, 3].find(x => true));
`,
},
],
},
],
},
{
code: `
Math.random() < 0.5
? [1, 2, 3].find(x => true)
: [1, 2, 3].filter(x => true)[0];
`,
errors: [
{
line: 4,
messageId: 'preferFind',
suggestions: [
{
messageId: 'preferFindSuggestion',
output: `
Math.random() < 0.5
? [1, 2, 3].find(x => true)
: [1, 2, 3].find(x => true);
`,
},
],
},
],
},
{
code: `
declare const f: any, g: any;
const nestedTernaries = (
Math.random() < 0.5
Expand Down

0 comments on commit 9d1b79a

Please sign in to comment.