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

@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as eslint from 'eslint';
import * as ESTree from 'estree';
import { TSESTree } from '@typescript-eslint/utils';
export function createImportRuleListener(validateImport: (node: TSESTree.Literal, value: string) => any): eslint.Rule.RuleListener {
@@ -16,24 +17,24 @@ export function createImportRuleListener(validateImport: (node: TSESTree.Literal
return {
// import ??? from 'module'
ImportDeclaration: (node: any) => {
_checkImport((<TSESTree.ImportDeclaration>node).source);
ImportDeclaration: (node: ESTree.ImportDeclaration) => {
_checkImport((node as TSESTree.ImportDeclaration).source);
},
// import('module').then(...) OR await import('module')
['CallExpression[callee.type="Import"][arguments.length=1] > Literal']: (node: any) => {
['CallExpression[callee.type="Import"][arguments.length=1] > Literal']: (node: TSESTree.Literal) => {
_checkImport(node);
},
// import foo = ...
['TSImportEqualsDeclaration > TSExternalModuleReference > Literal']: (node: any) => {
['TSImportEqualsDeclaration > TSExternalModuleReference > Literal']: (node: TSESTree.Literal) => {
_checkImport(node);
},
// export ?? from 'module'
ExportAllDeclaration: (node: any) => {
_checkImport((<TSESTree.ExportAllDeclaration>node).source);
ExportAllDeclaration: (node: ESTree.ExportAllDeclaration) => {
_checkImport((node as TSESTree.ExportAllDeclaration).source);
},
// export {foo} from 'module'
ExportNamedDeclaration: (node: any) => {
_checkImport((<TSESTree.ExportNamedDeclaration>node).source);
ExportNamedDeclaration: (node: ESTree.ExportNamedDeclaration) => {
_checkImport((node as TSESTree.ExportNamedDeclaration).source);
},
};