Skip to content

Commit

Permalink
fix(eslint-plugin): [no-explicit-any] error with ignoreRestArgs (#1796)
Browse files Browse the repository at this point in the history
  • Loading branch information
doniyor2109 committed Mar 26, 2020
1 parent 4fa7107 commit 638d84d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/eslint-plugin/src/rules/no-explicit-any.ts
Expand Up @@ -131,9 +131,7 @@ export default util.createRule<Options, MessageIds>({
*/
function isGreatGrandparentRestElement(node: TSESTree.Node): boolean {
return (
typeof node.parent !== 'undefined' &&
typeof node.parent.parent !== 'undefined' &&
typeof node.parent.parent.parent !== 'undefined' &&
node?.parent?.parent?.parent != null &&
isNodeRestElementInFunction(node.parent.parent.parent)
);
}
Expand All @@ -146,11 +144,8 @@ export default util.createRule<Options, MessageIds>({
*/
function isGreatGreatGrandparentRestElement(node: TSESTree.Node): boolean {
return (
typeof node.parent !== 'undefined' &&
typeof node.parent.parent !== 'undefined' &&
node.parent?.parent?.parent?.parent != null &&
isNodeValidTSType(node.parent.parent) &&
typeof node.parent.parent.parent !== 'undefined' &&
typeof node.parent.parent.parent.parent !== 'undefined' &&
isNodeRestElementInFunction(node.parent.parent.parent.parent)
);
}
Expand Down
11 changes: 11 additions & 0 deletions packages/eslint-plugin/tests/rules/no-explicit-any.test.ts
Expand Up @@ -925,6 +925,17 @@ const test = <T extends Partial<never>>() => {};
},
],
},
{
code: `type Any = any;`,
options: [{ ignoreRestArgs: true }],
errors: [
{
messageId: 'unexpectedAny',
line: 1,
column: 12,
},
],
},
{
code: `function foo5(...args: any) {}`,
options: [{ ignoreRestArgs: true }],
Expand Down

0 comments on commit 638d84d

Please sign in to comment.