Reduce any typings in our eslint rules

This commit is contained in:
Matt Bierner
2025-11-10 13:49:24 -08:00
parent 734a949cad
commit 1d2bb43237
32 changed files with 123 additions and 83 deletions

View File

@@ -11,8 +11,8 @@
* @author Michael Ficarra
*/
import * as eslint from 'eslint';
import { TSESTree } from '@typescript-eslint/utils';
import * as eslint from 'eslint';
import * as ESTree from 'estree';
//------------------------------------------------------------------------------
@@ -58,7 +58,7 @@ module.exports = {
allowTernary = config.allowTernary || false,
allowTaggedTemplates = config.allowTaggedTemplates || false;
/**
* @param node any node
* @returns whether the given node structurally represents a directive
@@ -68,7 +68,7 @@ module.exports = {
node.expression.type === 'Literal' && typeof node.expression.value === 'string';
}
/**
* @param predicate ([a] -> Boolean) the function used to make the determination
* @param list the input list
@@ -83,7 +83,7 @@ module.exports = {
return list.slice();
}
/**
* @param node a Program or BlockStatement node
* @returns the leading sequence of directive nodes in the given node's body
@@ -92,7 +92,7 @@ module.exports = {
return takeWhile(looksLikeDirective, node.body);
}
/**
* @param node any node
* @param ancestors the given node's ancestors
@@ -141,7 +141,7 @@ module.exports = {
return {
ExpressionStatement(node: TSESTree.ExpressionStatement) {
if (!isValidExpression(node.expression) && !isDirective(node, <TSESTree.Node[]>context.sourceCode.getAncestors(node))) {
if (!isValidExpression(node.expression) && !isDirective(node, <TSESTree.Node[]>context.sourceCode.getAncestors(node as ESTree.Node))) {
context.report({ node: <ESTree.Node>node, message: `Expected an assignment or function call and instead saw an expression. ${node.expression}` });
}
}