Skip to content
Permalink
Browse files

fix(eslint-plugin): [typedef] false positive for rest parameter with …

…array destructuring (#2441)
  • Loading branch information
gaonK committed Sep 6, 2020
1 parent cdb9807 commit 2ada5aff1ef37bc260d7a0eaafe9ff04f8a08fe4
Showing with 22 additions and 0 deletions.
  1. +6 −0 packages/eslint-plugin/src/rules/typedef.ts
  2. +16 −0 packages/eslint-plugin/tests/rules/typedef.test.ts
@@ -141,6 +141,12 @@ export default util.createRule<[Options], MessageIds>({

return {
ArrayPattern(node): void {
if (
node.parent?.type === AST_NODE_TYPES.RestElement &&
node.parent.typeAnnotation
) {
return;
}
if (
options[OptionKeys.ArrayDestructuring] &&
!node.typeAnnotation &&
@@ -14,6 +14,22 @@ const ruleTester = new RuleTester({
ruleTester.run('typedef', rule, {
valid: [
// Array destructuring
{
code: 'function foo(...[a]: string[]) {}',
options: [
{
arrayDestructuring: true,
},
],
},
{
code: 'const foo = (...[a]: string[]) => {};',
options: [
{
arrayDestructuring: true,
},
],
},
{
code: 'const [a]: [number] = [1];',
options: [

0 comments on commit 2ada5af

Please sign in to comment.