Skip to content

Commit

Permalink
fix(eslint-plugin): [no-extra-parens] handle generic ts array type. (#…
Browse files Browse the repository at this point in the history
…5550)

Co-authored-by: Josh Goldberg <me@joshuakgoldberg.com>
  • Loading branch information
zhyd1997 and JoshuaKGoldberg committed Sep 4, 2022
1 parent 6634e86 commit 0d6a190
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/eslint-plugin/src/rules/no-extra-parens.ts
Expand Up @@ -79,7 +79,9 @@ export default util.createRule<Options, MessageIds>({
if (
node.arguments.length === 1 &&
node.typeParameters?.params.some(
param => param.type === AST_NODE_TYPES.TSImportType,
param =>
param.type === AST_NODE_TYPES.TSImportType ||
param.type === AST_NODE_TYPES.TSArrayType,
)
) {
return rule({
Expand Down
11 changes: 11 additions & 0 deletions packages/eslint-plugin/tests/rules/no-extra-parens.test.ts
Expand Up @@ -227,6 +227,17 @@ switch (foo) { case 1: case (<2>2): break; default: break; }
},
],
}),
...batchedSingleLineTests({
code: `
declare const f: <T>(x: T) => any
f<(number | string)[]>(['a', 1])
`,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
}),
],

invalid: [
Expand Down

0 comments on commit 0d6a190

Please sign in to comment.