Skip to content

Commit

Permalink
fix(eslint-plugin): [typedef] stop enforcing rule for assignment expr…
Browse files Browse the repository at this point in the history
…essions (#4958)
  • Loading branch information
danstiner committed May 16, 2022
1 parent 2f57f3f commit 04a216c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/eslint-plugin/src/rules/typedef.ts
Expand Up @@ -178,7 +178,11 @@ export default util.createRule<[Options], MessageIds>({
return;
}

if (!node.typeAnnotation && !isForOfStatementContext(node)) {
if (
!node.typeAnnotation &&
!isForOfStatementContext(node) &&
node.parent?.type !== AST_NODE_TYPES.AssignmentExpression
) {
report(node);
}
},
Expand Down
26 changes: 25 additions & 1 deletion packages/eslint-plugin/tests/rules/typedef.test.ts
Expand Up @@ -47,7 +47,31 @@ ruleTester.run('typedef', rule, {
],
},
{
code: 'const [a] = 1;',
code: '[a] = [1];',
options: [
{
arrayDestructuring: true,
},
],
},
{
code: 'b = [a] = [1];',
options: [
{
arrayDestructuring: true,
},
],
},
{
code: 'const [b]: [number] = ([a] = [1]);',
options: [
{
arrayDestructuring: true,
},
],
},
{
code: 'const [a] = [1];',
options: [
{
arrayDestructuring: false,
Expand Down

0 comments on commit 04a216c

Please sign in to comment.