Skip to content

Commit

Permalink
feat(eslint-plugin): test spreading promises in arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
papermana committed May 24, 2022
1 parent bcdbc12 commit b41256c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/eslint-plugin/tests/rules/no-misused-promises.test.ts
Expand Up @@ -334,6 +334,9 @@ console.log({ ...(condition && (await Promise.resolve({ key: 42 }))) });
console.log({ ...(condition || (await Promise.resolve({ key: 42 }))) });
console.log({ ...(condition ? {} : await Promise.resolve({ key: 42 })) });
console.log({ ...(condition ? await Promise.resolve({ key: 42 }) : {}) });
`,
`
console.log([...(await Promise.resolve(42))]);
`,
{
code: `
Expand Down Expand Up @@ -363,6 +366,13 @@ console.log({ ...(condition ? Promise.resolve({ key: 42 }) : {}) });
`,
options: [{ checksSpreads: false }],
},
{
code: `
// This is invalid Typescript, but it shouldn't trigger this linter specifically
console.log([...Promise.resolve(42)]);
`,
options: [{ checksSpreads: false }],
},
],

invalid: [
Expand Down

0 comments on commit b41256c

Please sign in to comment.