diff --git a/.eslint-plugin-local/code-amd-node-module.ts b/.eslint-plugin-local/code-amd-node-module.ts index b622c98a89a..ea427658612 100644 --- a/.eslint-plugin-local/code-amd-node-module.ts +++ b/.eslint-plugin-local/code-amd-node-module.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import * as ESTree from 'estree'; import { join } from 'path'; @@ -33,13 +34,13 @@ export = new class ApiProviderNaming implements eslint.Rule.RuleModule { } - const checkImport = (node: any) => { + const checkImport = (node: ESTree.Literal & { parent?: ESTree.Node & { importKind?: string } }) => { - if (node.type !== 'Literal' || typeof node.value !== 'string') { + if (typeof node.value !== 'string') { return; } - if (node.parent.importKind === 'type') { + if (node.parent?.type === 'ImportDeclaration' && node.parent.importKind === 'type') { return; } diff --git a/.eslint-plugin-local/code-declare-service-brand.ts b/.eslint-plugin-local/code-declare-service-brand.ts index 85cf0671545..0aa0dab2a6d 100644 --- a/.eslint-plugin-local/code-declare-service-brand.ts +++ b/.eslint-plugin-local/code-declare-service-brand.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import * as ESTree from 'estree'; export = new class DeclareServiceBrand implements eslint.Rule.RuleModule { @@ -14,7 +15,7 @@ export = new class DeclareServiceBrand implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { return { - ['PropertyDefinition[key.name="_serviceBrand"][value]']: (node: any) => { + ['PropertyDefinition[key.name="_serviceBrand"][value]']: (node: ESTree.PropertyDefinition) => { return context.report({ node, message: `The '_serviceBrand'-property should not have a value`, diff --git a/.eslint-plugin-local/code-limited-top-functions.ts b/.eslint-plugin-local/code-limited-top-functions.ts index 7b48d02a0fe..6f54d169e30 100644 --- a/.eslint-plugin-local/code-limited-top-functions.ts +++ b/.eslint-plugin-local/code-limited-top-functions.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import * as ESTree from 'estree'; import { dirname, relative } from 'path'; import minimatch from 'minimatch'; @@ -43,21 +44,29 @@ export = new class implements eslint.Rule.RuleModule { const restrictedFunctions = ruleArgs[matchingKey]; return { - FunctionDeclaration: (node: any) => { - const isTopLevel = node.parent.type === 'Program'; - const functionName = node.id.name; - if (isTopLevel && !restrictedFunctions.includes(node.id.name)) { + FunctionDeclaration: (node: ESTree.Node) => { + const functionDeclaration = node as ESTree.FunctionDeclaration & { parent?: ESTree.Node }; + if (!functionDeclaration.id) { + return; + } + const isTopLevel = functionDeclaration.parent?.type === 'Program'; + const functionName = functionDeclaration.id.name; + if (isTopLevel && !restrictedFunctions.includes(functionName)) { context.report({ node, message: `Top-level function '${functionName}' is restricted in this file. Allowed functions are: ${restrictedFunctions.join(', ')}.` }); } }, - ExportNamedDeclaration(node: any) { + ExportNamedDeclaration(node: ESTree.ExportNamedDeclaration & { parent?: ESTree.Node }) { if (node.declaration && node.declaration.type === 'FunctionDeclaration') { - const functionName = node.declaration.id.name; - const isTopLevel = node.parent.type === 'Program'; - if (isTopLevel && !restrictedFunctions.includes(node.declaration.id.name)) { + const declaration = node.declaration as ESTree.FunctionDeclaration & { parent?: ESTree.Node }; + if (!declaration.id) { + return; + } + const functionName = declaration.id.name; + const isTopLevel = node.parent?.type === 'Program'; + if (isTopLevel && !restrictedFunctions.includes(functionName)) { context.report({ node, message: `Top-level function '${functionName}' is restricted in this file. Allowed functions are: ${restrictedFunctions.join(', ')}.` diff --git a/.eslint-plugin-local/code-must-use-result.ts b/.eslint-plugin-local/code-must-use-result.ts index e249f36dccf..5f43b87ff12 100644 --- a/.eslint-plugin-local/code-must-use-result.ts +++ b/.eslint-plugin-local/code-must-use-result.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import * as ESTree from 'estree'; import { TSESTree } from '@typescript-eslint/utils'; const VALID_USES = new Set([ @@ -24,9 +25,9 @@ export = new class MustUseResults implements eslint.Rule.RuleModule { for (const { message, functions } of config) { for (const fn of functions) { const query = `CallExpression[callee.property.name='${fn}'], CallExpression[callee.name='${fn}']`; - listener[query] = (node: any) => { - const cast: TSESTree.CallExpression = node; - if (!VALID_USES.has(cast.parent?.type)) { + listener[query] = (node: ESTree.Node) => { + const callExpression = node as TSESTree.CallExpression; + if (!VALID_USES.has(callExpression.parent?.type)) { context.report({ node, message }); } }; diff --git a/.eslint-plugin-local/code-must-use-super-dispose.ts b/.eslint-plugin-local/code-must-use-super-dispose.ts index ca776d8a2ad..ec23445611c 100644 --- a/.eslint-plugin-local/code-must-use-super-dispose.ts +++ b/.eslint-plugin-local/code-must-use-super-dispose.ts @@ -4,17 +4,19 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import * as ESTree from 'estree'; +import { TSESTree } from '@typescript-eslint/utils'; export = new class NoAsyncSuite implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { - function doesCallSuperDispose(node: any) { + function doesCallSuperDispose(node: TSESTree.MethodDefinition) { if (!node.override) { return; } - const body = context.getSourceCode().getText(node); + const body = context.getSourceCode().getText(node as ESTree.Node); if (body.includes('super.dispose')) { return; diff --git a/.eslint-plugin-local/code-no-dangerous-type-assertions.ts b/.eslint-plugin-local/code-no-dangerous-type-assertions.ts index 6c0fa26ca1a..f49c8d2eea3 100644 --- a/.eslint-plugin-local/code-no-dangerous-type-assertions.ts +++ b/.eslint-plugin-local/code-no-dangerous-type-assertions.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import * as ESTree from 'estree'; import { TSESTree } from '@typescript-eslint/utils'; export = new class NoDangerousTypeAssertions implements eslint.Rule.RuleModule { @@ -11,8 +12,8 @@ export = new class NoDangerousTypeAssertions implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { return { // Disallow type assertions on object literals: { ... } or {} as T - ['TSTypeAssertion > ObjectExpression, TSAsExpression > ObjectExpression']: (node: any) => { - const objectNode = node as TSESTree.Node; + ['TSTypeAssertion > ObjectExpression, TSAsExpression > ObjectExpression']: (node: ESTree.ObjectExpression) => { + const objectNode = node as TSESTree.ObjectExpression; const parent = objectNode.parent as TSESTree.TSTypeAssertion | TSESTree.TSAsExpression; if ( diff --git a/.eslint-plugin-local/code-no-deep-import-of-internal.ts b/.eslint-plugin-local/code-no-deep-import-of-internal.ts index 3f54665b49a..4aa5cf4b9c7 100644 --- a/.eslint-plugin-local/code-no-deep-import-of-internal.ts +++ b/.eslint-plugin-local/code-no-deep-import-of-internal.ts @@ -28,8 +28,8 @@ export = new class implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { const patterns = context.options[0] as Record; - const internalModulePattern = Object.entries(patterns).map(([key, v]) => v ? key : undefined).filter(v => !!v); - const allowedPatterns = Object.entries(patterns).map(([key, v]) => !v ? key : undefined).filter(v => !!v); + const internalModulePattern = Object.entries(patterns).map(([key, v]) => v ? key : undefined).filter((v): v is string => !!v); + const allowedPatterns = Object.entries(patterns).map(([key, v]) => !v ? key : undefined).filter((v): v is string => !!v); return createImportRuleListener((node, path) => { const importerModuleDir = dirname(context.filename); diff --git a/.eslint-plugin-local/code-no-in-operator.ts b/.eslint-plugin-local/code-no-in-operator.ts index dcfb1afc22e..9f2fb11ae80 100644 --- a/.eslint-plugin-local/code-no-in-operator.ts +++ b/.eslint-plugin-local/code-no-in-operator.ts @@ -4,6 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import * as ESTree from 'estree'; +import { TSESTree } from '@typescript-eslint/utils'; /** * Disallows the use of the `in` operator in TypeScript code, except within @@ -26,9 +28,10 @@ export = new class NoInOperator implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { - function checkInOperator(inNode: any) { + function checkInOperator(inNode: ESTree.BinaryExpression) { + const node = inNode as TSESTree.BinaryExpression; // Check if we're inside a type predicate function - const ancestors = context.sourceCode.getAncestors(inNode); + const ancestors = context.sourceCode.getAncestors(node as ESTree.Node); for (const ancestor of ancestors) { if (ancestor.type === 'FunctionDeclaration' || @@ -45,7 +48,7 @@ export = new class NoInOperator implements eslint.Rule.RuleModule { } context.report({ - node: inNode, + node, messageId: 'noInOperator' }); } diff --git a/.eslint-plugin-local/code-no-native-private.ts b/.eslint-plugin-local/code-no-native-private.ts index e2d20694ca8..96c326ec84c 100644 --- a/.eslint-plugin-local/code-no-native-private.ts +++ b/.eslint-plugin-local/code-no-native-private.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import * as ESTree from 'estree'; export = new class ApiProviderNaming implements eslint.Rule.RuleModule { @@ -17,13 +18,13 @@ export = new class ApiProviderNaming implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { return { - ['PropertyDefinition PrivateIdentifier']: (node: any) => { + ['PropertyDefinition PrivateIdentifier']: (node: ESTree.Node) => { context.report({ node, messageId: 'slow' }); }, - ['MethodDefinition PrivateIdentifier']: (node: any) => { + ['MethodDefinition PrivateIdentifier']: (node: ESTree.Node) => { context.report({ node, messageId: 'slow' diff --git a/.eslint-plugin-local/code-no-observable-get-in-reactive-context.ts b/.eslint-plugin-local/code-no-observable-get-in-reactive-context.ts index 2fa8e0bd9b5..d96cdd4a31b 100644 --- a/.eslint-plugin-local/code-no-observable-get-in-reactive-context.ts +++ b/.eslint-plugin-local/code-no-observable-get-in-reactive-context.ts @@ -19,7 +19,7 @@ export = new class NoObservableGetInReactiveContext implements eslint.Rule.RuleM create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { return { - 'CallExpression': (node: any) => { + 'CallExpression': (node: ESTree.CallExpression) => { const callExpression = node as TSESTree.CallExpression; if (!isReactiveFunctionWithReader(callExpression.callee)) { diff --git a/.eslint-plugin-local/code-no-potentially-unsafe-disposables.ts b/.eslint-plugin-local/code-no-potentially-unsafe-disposables.ts index 077ad081901..95b66aee4ac 100644 --- a/.eslint-plugin-local/code-no-potentially-unsafe-disposables.ts +++ b/.eslint-plugin-local/code-no-potentially-unsafe-disposables.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import * as ESTree from 'estree'; /** * Checks for potentially unsafe usage of `DisposableStore` / `MutableDisposable`. @@ -13,14 +14,14 @@ import * as eslint from 'eslint'; export = new class implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { - function checkVariableDeclaration(inNode: any) { + function checkVariableDeclaration(inNode: ESTree.Node) { context.report({ node: inNode, message: `Use const for 'DisposableStore' to avoid leaks by accidental reassignment.` }); } - function checkProperty(inNode: any) { + function checkProperty(inNode: ESTree.Node) { context.report({ node: inNode, message: `Use readonly for DisposableStore/MutableDisposable to avoid leaks through accidental reassignment.` diff --git a/.eslint-plugin-local/code-no-reader-after-await.ts b/.eslint-plugin-local/code-no-reader-after-await.ts index 545e1fd050a..8e95ee712f8 100644 --- a/.eslint-plugin-local/code-no-reader-after-await.ts +++ b/.eslint-plugin-local/code-no-reader-after-await.ts @@ -5,11 +5,12 @@ import { TSESTree } from '@typescript-eslint/utils'; import * as eslint from 'eslint'; +import * as ESTree from 'estree'; export = new class NoReaderAfterAwait implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { return { - 'CallExpression': (node: any) => { + 'CallExpression': (node: ESTree.CallExpression) => { const callExpression = node as TSESTree.CallExpression; if (!isFunctionWithReader(callExpression.callee)) { diff --git a/.eslint-plugin-local/code-no-static-self-ref.ts b/.eslint-plugin-local/code-no-static-self-ref.ts index 94287b8311c..2ba0bdd7845 100644 --- a/.eslint-plugin-local/code-no-static-self-ref.ts +++ b/.eslint-plugin-local/code-no-static-self-ref.ts @@ -14,10 +14,10 @@ export = new class implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { - function checkProperty(inNode: any) { + function checkProperty(inNode: TSESTree.PropertyDefinition) { - const classDeclaration = context.sourceCode.getAncestors(inNode).find(node => node.type === 'ClassDeclaration'); - const propertyDefinition = inNode; + const classDeclaration = context.sourceCode.getAncestors(inNode as ESTree.Node).find(node => node.type === 'ClassDeclaration'); + const propertyDefinition = inNode; if (!classDeclaration || !classDeclaration.id?.name) { return; diff --git a/.eslint-plugin-local/code-no-test-async-suite.ts b/.eslint-plugin-local/code-no-test-async-suite.ts index 60a0f2153ab..763d4d20c78 100644 --- a/.eslint-plugin-local/code-no-test-async-suite.ts +++ b/.eslint-plugin-local/code-no-test-async-suite.ts @@ -3,8 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TSESTree } from '@typescript-eslint/utils'; import * as eslint from 'eslint'; +import * as ESTree from 'estree'; +import { TSESTree } from '@typescript-eslint/utils'; function isCallExpression(node: TSESTree.Node): node is TSESTree.CallExpression { return node.type === 'CallExpression'; @@ -17,10 +18,11 @@ function isFunctionExpression(node: TSESTree.Node): node is TSESTree.FunctionExp export = new class NoAsyncSuite implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { - function hasAsyncSuite(node: any) { - if (isCallExpression(node) && node.arguments.length >= 2 && isFunctionExpression(node.arguments[1]) && node.arguments[1].async) { + function hasAsyncSuite(node: ESTree.Node) { + const tsNode = node as TSESTree.Node; + if (isCallExpression(tsNode) && tsNode.arguments.length >= 2 && isFunctionExpression(tsNode.arguments[1]) && tsNode.arguments[1].async) { return context.report({ - node: node, + node: tsNode, message: 'suite factory function should never be async' }); } diff --git a/.eslint-plugin-local/code-no-test-only.ts b/.eslint-plugin-local/code-no-test-only.ts index d4751eef2ee..a10ad9d5ba8 100644 --- a/.eslint-plugin-local/code-no-test-only.ts +++ b/.eslint-plugin-local/code-no-test-only.ts @@ -4,12 +4,13 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import * as ESTree from 'estree'; export = new class NoTestOnly implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { return { - ['MemberExpression[object.name=/^(test|suite)$/][property.name="only"]']: (node: any) => { + ['MemberExpression[object.name=/^(test|suite)$/][property.name="only"]']: (node: ESTree.MemberExpression) => { return context.report({ node, message: 'only is a dev-time tool and CANNOT be pushed' diff --git a/.eslint-plugin-local/code-no-unused-expressions.ts b/.eslint-plugin-local/code-no-unused-expressions.ts index bd632884dbd..160db2ab21c 100644 --- a/.eslint-plugin-local/code-no-unused-expressions.ts +++ b/.eslint-plugin-local/code-no-unused-expressions.ts @@ -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, context.sourceCode.getAncestors(node))) { + if (!isValidExpression(node.expression) && !isDirective(node, context.sourceCode.getAncestors(node as ESTree.Node))) { context.report({ node: node, message: `Expected an assignment or function call and instead saw an expression. ${node.expression}` }); } } diff --git a/.eslint-plugin-local/code-parameter-properties-must-have-explicit-accessibility.ts b/.eslint-plugin-local/code-parameter-properties-must-have-explicit-accessibility.ts index c9837052fa5..36a26557346 100644 --- a/.eslint-plugin-local/code-parameter-properties-must-have-explicit-accessibility.ts +++ b/.eslint-plugin-local/code-parameter-properties-must-have-explicit-accessibility.ts @@ -3,8 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as eslint from 'eslint'; import { TSESTree } from '@typescript-eslint/utils'; +import * as eslint from 'eslint'; /** * Enforces that all parameter properties have an explicit access modifier (public, protected, private). @@ -14,8 +14,7 @@ import { TSESTree } from '@typescript-eslint/utils'; export = new class implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { - function check(inNode: any) { - const node: TSESTree.TSParameterProperty = inNode; + function check(node: TSESTree.TSParameterProperty) { // For now, only apply to injected services const firstDecorator = node.decorators?.at(0); @@ -28,7 +27,7 @@ export = new class implements eslint.Rule.RuleModule { if (!node.accessibility) { context.report({ - node: inNode, + node: node, message: 'Parameter properties must have an explicit access modifier.' }); } diff --git a/.eslint-plugin-local/code-policy-localization-key-match.ts b/.eslint-plugin-local/code-policy-localization-key-match.ts index 6cfc7cbfbc7..c646f768a3a 100644 --- a/.eslint-plugin-local/code-policy-localization-key-match.ts +++ b/.eslint-plugin-local/code-policy-localization-key-match.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import * as ESTree from 'estree'; /** * Ensures that localization keys in policy blocks match the keys used in nls.localize() calls. @@ -35,11 +36,11 @@ export = new class PolicyLocalizationKeyMatch implements eslint.Rule.RuleModule create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { - function checkLocalizationObject(node: any) { + function checkLocalizationObject(node: ESTree.ObjectExpression) { // Look for objects with structure: { key: '...', value: nls.localize('...', '...') } - let keyProperty: any; - let valueProperty: any; + let keyProperty: ESTree.Property | undefined; + let valueProperty: ESTree.Property | undefined; for (const property of node.properties) { if (property.type !== 'Property') { @@ -113,7 +114,7 @@ export = new class PolicyLocalizationKeyMatch implements eslint.Rule.RuleModule } } - function isInPolicyBlock(node: any): boolean { + function isInPolicyBlock(node: ESTree.Node): boolean { // Walk up the AST to see if we're inside a policy object const ancestors = context.sourceCode.getAncestors(node); @@ -131,7 +132,7 @@ export = new class PolicyLocalizationKeyMatch implements eslint.Rule.RuleModule } return { - 'ObjectExpression': (node: any) => { + 'ObjectExpression': (node: ESTree.ObjectExpression) => { // Only check objects inside policy blocks if (!isInPolicyBlock(node)) { return; diff --git a/.eslint-plugin-local/index.js b/.eslint-plugin-local/index.js index ad00191fb6f..bc6d9d3c3dc 100644 --- a/.eslint-plugin-local/index.js +++ b/.eslint-plugin-local/index.js @@ -16,7 +16,7 @@ require('ts-node').register({ }); // Re-export all .ts files as rules -/** @type {Record} */ +/** @type {Record} */ const rules = {}; glob.sync(`${__dirname}/*.ts`).forEach((file) => { rules[path.basename(file, '.ts')] = require(file); diff --git a/.eslint-plugin-local/package.json b/.eslint-plugin-local/package.json index a0df0c86778..a03f28ed036 100644 --- a/.eslint-plugin-local/package.json +++ b/.eslint-plugin-local/package.json @@ -1,3 +1,6 @@ { - "type": "commonjs" + "type": "commonjs", + "scripts": { + "typecheck": "tsgo -p tsconfig.json --noEmit" + } } diff --git a/.eslint-plugin-local/tsconfig.json b/.eslint-plugin-local/tsconfig.json index 7676f59a781..a087877ecd4 100644 --- a/.eslint-plugin-local/tsconfig.json +++ b/.eslint-plugin-local/tsconfig.json @@ -4,6 +4,7 @@ "lib": [ "ES2024" ], + "rootDir": ".", "module": "commonjs", "esModuleInterop": true, "alwaysStrict": true, @@ -14,13 +15,17 @@ "noUnusedLocals": true, "noUnusedParameters": true, "newLine": "lf", - "noEmit": true + "noEmit": true, + "typeRoots": [ + "." + ] }, "include": [ - "**/*.ts", - "**/*.js" + "./**/*.ts", + "./**/*.js" ], "exclude": [ - "node_modules/**" + "node_modules/**", + "tests/**" ] } diff --git a/.eslint-plugin-local/utils.ts b/.eslint-plugin-local/utils.ts index b7457884f85..63a5f58917b 100644 --- a/.eslint-plugin-local/utils.ts +++ b/.eslint-plugin-local/utils.ts @@ -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((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((node).source); + ExportAllDeclaration: (node: ESTree.ExportAllDeclaration) => { + _checkImport((node as TSESTree.ExportAllDeclaration).source); }, // export {foo} from 'module' - ExportNamedDeclaration: (node: any) => { - _checkImport((node).source); + ExportNamedDeclaration: (node: ESTree.ExportNamedDeclaration) => { + _checkImport((node as TSESTree.ExportNamedDeclaration).source); }, }; diff --git a/.eslint-plugin-local/vscode-dts-cancellation.ts b/.eslint-plugin-local/vscode-dts-cancellation.ts index 5e8e875af21..aabdfcfd05b 100644 --- a/.eslint-plugin-local/vscode-dts-cancellation.ts +++ b/.eslint-plugin-local/vscode-dts-cancellation.ts @@ -3,8 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as eslint from 'eslint'; import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/utils'; +import * as eslint from 'eslint'; export = new class ApiProviderNaming implements eslint.Rule.RuleModule { @@ -18,7 +18,7 @@ export = new class ApiProviderNaming implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { return { - ['TSInterfaceDeclaration[id.name=/.+Provider/] TSMethodSignature[key.name=/^(provide|resolve).+/]']: (node: any) => { + ['TSInterfaceDeclaration[id.name=/.+Provider/] TSMethodSignature[key.name=/^(provide|resolve).+/]']: (node: TSESTree.Node) => { let found = false; for (const param of (node).params) { diff --git a/.eslint-plugin-local/vscode-dts-create-func.ts b/.eslint-plugin-local/vscode-dts-create-func.ts index 01db244ce76..3ce5ec07e8c 100644 --- a/.eslint-plugin-local/vscode-dts-create-func.ts +++ b/.eslint-plugin-local/vscode-dts-create-func.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import * as ESTree from 'estree'; import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/utils'; export = new class ApiLiteralOrTypes implements eslint.Rule.RuleModule { @@ -17,7 +18,7 @@ export = new class ApiLiteralOrTypes implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { return { - ['TSDeclareFunction Identifier[name=/create.*/]']: (node: any) => { + ['TSDeclareFunction Identifier[name=/create.*/]']: (node: ESTree.Node) => { const decl = (node).parent; diff --git a/.eslint-plugin-local/vscode-dts-event-naming.ts b/.eslint-plugin-local/vscode-dts-event-naming.ts index c27d934f4f9..230fdc60332 100644 --- a/.eslint-plugin-local/vscode-dts-event-naming.ts +++ b/.eslint-plugin-local/vscode-dts-event-naming.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import * as ESTree from 'estree'; import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/utils'; export = new class ApiEventNaming implements eslint.Rule.RuleModule { @@ -30,7 +31,7 @@ export = new class ApiEventNaming implements eslint.Rule.RuleModule { const verbs = new Set(config.verbs); return { - ['TSTypeAnnotation TSTypeReference Identifier[name="Event"]']: (node: any) => { + ['TSTypeAnnotation TSTypeReference Identifier[name="Event"]']: (node: ESTree.Identifier) => { const def = (node).parent?.parent?.parent; const ident = this.getIdent(def); diff --git a/.eslint-plugin-local/vscode-dts-interface-naming.ts b/.eslint-plugin-local/vscode-dts-interface-naming.ts index 6b33f9c5343..85f81720663 100644 --- a/.eslint-plugin-local/vscode-dts-interface-naming.ts +++ b/.eslint-plugin-local/vscode-dts-interface-naming.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import * as ESTree from 'estree'; import { TSESTree } from '@typescript-eslint/utils'; export = new class ApiInterfaceNaming implements eslint.Rule.RuleModule { @@ -20,7 +21,7 @@ export = new class ApiInterfaceNaming implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { return { - ['TSInterfaceDeclaration Identifier']: (node: any) => { + ['TSInterfaceDeclaration Identifier']: (node: ESTree.Identifier) => { const name = (node).name; if (ApiInterfaceNaming._nameRegExp.test(name)) { diff --git a/.eslint-plugin-local/vscode-dts-literal-or-types.ts b/.eslint-plugin-local/vscode-dts-literal-or-types.ts index 44ef0fd2a7c..2d1dac279df 100644 --- a/.eslint-plugin-local/vscode-dts-literal-or-types.ts +++ b/.eslint-plugin-local/vscode-dts-literal-or-types.ts @@ -3,8 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as eslint from 'eslint'; import { TSESTree } from '@typescript-eslint/utils'; +import * as eslint from 'eslint'; export = new class ApiLiteralOrTypes implements eslint.Rule.RuleModule { @@ -16,8 +16,8 @@ export = new class ApiLiteralOrTypes implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { return { - ['TSTypeAnnotation TSUnionType']: (node: any) => { - if ((node).types.every(value => value.type === 'TSLiteralType')) { + ['TSTypeAnnotation TSUnionType']: (node: TSESTree.TSUnionType) => { + if (node.types.every(value => value.type === 'TSLiteralType')) { context.report({ node: node, messageId: 'useEnum' diff --git a/.eslint-plugin-local/vscode-dts-provider-naming.ts b/.eslint-plugin-local/vscode-dts-provider-naming.ts index 90409bfe058..19338a65ab4 100644 --- a/.eslint-plugin-local/vscode-dts-provider-naming.ts +++ b/.eslint-plugin-local/vscode-dts-provider-naming.ts @@ -3,8 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as eslint from 'eslint'; import { TSESTree } from '@typescript-eslint/utils'; +import * as eslint from 'eslint'; export = new class ApiProviderNaming implements eslint.Rule.RuleModule { @@ -23,7 +23,7 @@ export = new class ApiProviderNaming implements eslint.Rule.RuleModule { const allowed = new Set(config.allowed); return { - ['TSInterfaceDeclaration[id.name=/.+Provider/] TSMethodSignature']: (node: any) => { + ['TSInterfaceDeclaration[id.name=/.+Provider/] TSMethodSignature']: (node: TSESTree.Node) => { const interfaceName = ((node).parent?.parent).id.name; if (allowed.has(interfaceName)) { // allowed diff --git a/.eslint-plugin-local/vscode-dts-string-type-literals.ts b/.eslint-plugin-local/vscode-dts-string-type-literals.ts index 0f6d711a3db..1f8bc96ca17 100644 --- a/.eslint-plugin-local/vscode-dts-string-type-literals.ts +++ b/.eslint-plugin-local/vscode-dts-string-type-literals.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import * as ESTree from 'estree'; import { TSESTree } from '@typescript-eslint/utils'; export = new class ApiTypeDiscrimination implements eslint.Rule.RuleModule { @@ -18,8 +19,8 @@ export = new class ApiTypeDiscrimination implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { return { - ['TSPropertySignature[optional=false] TSTypeAnnotation TSLiteralType Literal']: (node: any) => { - const raw = String((node).raw); + ['TSPropertySignature[optional=false] TSTypeAnnotation TSLiteralType Literal']: (node: ESTree.Literal) => { + const raw = String((node as TSESTree.Literal).raw); if (/^('|").*\1$/.test(raw)) { diff --git a/.eslint-plugin-local/vscode-dts-use-export.ts b/.eslint-plugin-local/vscode-dts-use-export.ts index 904feaeec36..ab19e9eedce 100644 --- a/.eslint-plugin-local/vscode-dts-use-export.ts +++ b/.eslint-plugin-local/vscode-dts-use-export.ts @@ -5,6 +5,7 @@ import { TSESTree } from '@typescript-eslint/utils'; import * as eslint from 'eslint'; +import * as ESTree from 'estree'; export = new class VscodeDtsUseExport implements eslint.Rule.RuleModule { @@ -17,8 +18,8 @@ export = new class VscodeDtsUseExport implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { return { - ['TSModuleDeclaration :matches(TSInterfaceDeclaration, ClassDeclaration, VariableDeclaration, TSEnumDeclaration, TSTypeAliasDeclaration)']: (node: any) => { - const parent = (node).parent; + ['TSModuleDeclaration :matches(TSInterfaceDeclaration, ClassDeclaration, VariableDeclaration, TSEnumDeclaration, TSTypeAliasDeclaration)']: (node: ESTree.Node) => { + const parent = (node as TSESTree.Node).parent; if (parent && parent.type !== TSESTree.AST_NODE_TYPES.ExportNamedDeclaration) { context.report({ node, diff --git a/.eslint-plugin-local/vscode-dts-use-thenable.ts b/.eslint-plugin-local/vscode-dts-use-thenable.ts index 683394ad115..40e7d10a45b 100644 --- a/.eslint-plugin-local/vscode-dts-use-thenable.ts +++ b/.eslint-plugin-local/vscode-dts-use-thenable.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import * as ESTree from 'estree'; export = new class ApiEventNaming implements eslint.Rule.RuleModule { @@ -19,7 +20,7 @@ export = new class ApiEventNaming implements eslint.Rule.RuleModule { return { - ['TSTypeAnnotation TSTypeReference Identifier[name="Promise"]']: (node: any) => { + ['TSTypeAnnotation TSTypeReference Identifier[name="Promise"]']: (node: ESTree.Identifier) => { context.report({ node, diff --git a/.eslint-plugin-local/vscode-dts-vscode-in-comments.ts b/.eslint-plugin-local/vscode-dts-vscode-in-comments.ts index 33fd44d8af6..63c59bf03ae 100644 --- a/.eslint-plugin-local/vscode-dts-vscode-in-comments.ts +++ b/.eslint-plugin-local/vscode-dts-vscode-in-comments.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import * as ESTree from 'estree'; export = new class ApiVsCodeInComments implements eslint.Rule.RuleModule { @@ -19,7 +20,7 @@ export = new class ApiVsCodeInComments implements eslint.Rule.RuleModule { const sourceCode = context.getSourceCode(); return { - ['Program']: (_node: any) => { + ['Program']: (_node: ESTree.Program) => { for (const comment of sourceCode.getAllComments()) { if (comment.type !== 'Block') {