Skip to content

fix(eslint-plugin): [no-explicit-any] error with ignoreRestArgs option #1796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions packages/eslint-plugin/src/rules/no-explicit-any.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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