Skip to content
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

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

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 4 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,10 @@ 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 != null &&
isNodeValidTSType(node.parent.parent) &&
typeof node.parent.parent.parent !== 'undefined' &&
typeof node.parent.parent.parent.parent !== 'undefined' &&
node.parent.parent.parent != null &&
node.parent.parent.parent.parent != null &&
isNodeRestElementInFunction(node.parent.parent.parent.parent)
bradzacher marked this conversation as resolved.
Show resolved Hide resolved
);
}
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