Upgrade to ESLint 9

This commit is contained in:
Alex
2024-10-16 00:29:26 -04:00
parent 0138cabb27
commit 00d0dfa107
53 changed files with 3813 additions and 2207 deletions

View File

@ -6,7 +6,12 @@ import {
isTypeFlagSet,
isTypeNeverType,
} from '@typescript-eslint/type-utils';
import { AST_NODE_TYPES, ESLintUtils, type TSESTree } from '@typescript-eslint/utils';
import {
AST_NODE_TYPES,
ESLintUtils,
ParserServicesWithTypeInformation,
type TSESTree,
} from '@typescript-eslint/utils';
import { getParserServices } from '@typescript-eslint/utils/eslint-utils';
import * as ts from 'typescript';
@ -52,8 +57,14 @@ export default createRule<Option[], MessageId>({
},
defaultOptions: [defaultOption],
create(context, [options]) {
const services = getParserServices(context);
if (!services.program) return {};
let services: ParserServicesWithTypeInformation | undefined;
try {
services = getParserServices(context);
} catch (error) {
console.error(error);
}
if (!services?.program) return {};
const checker = services.program.getTypeChecker();
const allowed = new Set(options.allow);