Skip to content

Commit f07ee64

Browse files
feat(deps): update to @typescript-eslint/* v6 (#945)
1 parent 33bde4f commit f07ee64

17 files changed

+613
-340
lines changed

.eslintrc.js

+2-13
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,6 @@ module.exports = {
1414
rules: {
1515
// Base
1616
'max-lines-per-function': 'off',
17-
'no-restricted-imports': [
18-
'error',
19-
{
20-
patterns: [
21-
{
22-
group: ['@typescript-eslint/utils/dist/*'],
23-
message: 'Import from `@typescript-eslint/utils` instead.',
24-
},
25-
],
26-
},
27-
],
2817

2918
// Import
3019
'import/order': [
@@ -51,12 +40,12 @@ module.exports = {
5140
files: ['**/*.ts?(x)'],
5241
parser: '@typescript-eslint/parser',
5342
parserOptions: {
43+
project: './tsconfig.eslint.json',
5444
tsconfigRootDir: __dirname,
55-
project: ['./tsconfig.eslint.json'],
5645
},
5746
extends: [
5847
'plugin:@typescript-eslint/recommended',
59-
'plugin:@typescript-eslint/recommended-requiring-type-checking',
48+
'plugin:@typescript-eslint/recommended-type-checked',
6049
'plugin:import/typescript',
6150
],
6251
rules: {

lib/configs/index.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
import { join } from 'path';
22

3-
import { type TSESLint } from '@typescript-eslint/utils';
3+
import type { TSESLint } from '@typescript-eslint/utils';
44

55
import {
66
importDefault,
77
SUPPORTED_TESTING_FRAMEWORKS,
88
SupportedTestingFramework,
99
} from '../utils';
1010

11-
export type LinterConfigRules = Pick<Required<TSESLint.Linter.Config>, 'rules'>;
12-
1311
const configsDir = __dirname;
1412

1513
const getConfigForFramework = (framework: SupportedTestingFramework) =>
16-
importDefault<LinterConfigRules>(join(configsDir, framework));
14+
importDefault<TSESLint.SharedConfig.RulesRecord>(join(configsDir, framework));
1715

1816
export default SUPPORTED_TESTING_FRAMEWORKS.reduce(
1917
(allConfigs, framework) => ({
2018
...allConfigs,
2119
[framework]: getConfigForFramework(framework),
2220
}),
2321
{}
24-
) as Record<SupportedTestingFramework, LinterConfigRules>;
22+
) as Record<SupportedTestingFramework, TSESLint.SharedConfig.RulesRecord>;

lib/create-testing-library-rule/detect-testing-library-utils.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ import {
2828
const SETTING_OPTION_OFF = 'off' as const;
2929

3030
export type TestingLibrarySettings = {
31-
'testing-library/utils-module'?: string | typeof SETTING_OPTION_OFF;
31+
'testing-library/utils-module'?:
32+
| typeof SETTING_OPTION_OFF
33+
| (string & NonNullable<unknown>);
3234
'testing-library/custom-renders'?: string[] | typeof SETTING_OPTION_OFF;
3335
'testing-library/custom-queries'?: string[] | typeof SETTING_OPTION_OFF;
3436
};

lib/create-testing-library-rule/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function createTestingLibraryRule<
3737
...meta.docs,
3838
// We're using our own recommendedConfig meta to tell our build tools
3939
// if the rule is recommended on a config basis
40-
recommended: false,
40+
recommended: undefined,
4141
},
4242
},
4343
});

lib/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const plugin = {
2020
// we don't have types for flat config yet
2121
configs: {} as Record<
2222
SupportedTestingFramework | `flat/${SupportedTestingFramework}`,
23-
Pick<Required<TSESLint.Linter.Config>, 'rules'>
23+
TSESLint.SharedConfig.RulesRecord
2424
>,
2525
rules,
2626
};
@@ -35,9 +35,9 @@ plugin.configs = {
3535
rules: config.rules,
3636
},
3737
])
38-
) as Record<
38+
) as unknown as Record<
3939
`flat/${SupportedTestingFramework}`,
40-
Pick<Required<TSESLint.Linter.Config>, 'rules'> & { plugins: unknown }
40+
TSESLint.SharedConfig.RulesRecord & { plugins: unknown }
4141
>),
4242
};
4343

lib/node-utils/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { FunctionScope, ScopeType } from '@typescript-eslint/scope-manager';
12
import {
23
AST_NODE_TYPES,
34
ASTUtils,
45
TSESLint,
5-
TSESLintScope,
66
TSESTree,
77
} from '@typescript-eslint/utils';
88

@@ -188,7 +188,7 @@ export function isPromiseAllSettled(node: TSESTree.CallExpression): boolean {
188188
}
189189

190190
/**
191-
* Determines whether a given node belongs to handled Promise.all or Promise.allSettled
191+
* Determines whether a given node belongs to handled `Promise.all` or `Promise.allSettled`
192192
* array expression.
193193
*/
194194
export function isPromisesArrayResolved(node: TSESTree.Node): boolean {
@@ -295,7 +295,7 @@ export function getVariableReferences(
295295
return [];
296296
}
297297

298-
interface InnermostFunctionScope extends TSESLintScope.FunctionScope {
298+
interface InnermostFunctionScope extends FunctionScope {
299299
block:
300300
| TSESTree.ArrowFunctionExpression
301301
| TSESTree.FunctionDeclaration
@@ -312,7 +312,7 @@ export function getInnermostFunctionScope(
312312
);
313313

314314
if (
315-
innermostScope.type === 'function' &&
315+
innermostScope.type === ScopeType.function &&
316316
ASTUtils.isFunction(innermostScope.block)
317317
) {
318318
return innermostScope as unknown as InnermostFunctionScope;

lib/rules/await-async-events.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ export default createTestingLibraryRule<Options, MessageIds>({
5555
default: USER_EVENT_NAME,
5656
oneOf: [
5757
{
58+
enum: EVENTS_SIMULATORS.concat(),
5859
type: 'string',
59-
enum: EVENTS_SIMULATORS,
6060
},
6161
{
62-
type: 'array',
6362
items: {
6463
type: 'string',
65-
enum: EVENTS_SIMULATORS,
64+
enum: EVENTS_SIMULATORS.concat(),
6665
},
66+
type: 'array',
6767
},
6868
],
6969
},

lib/rules/no-debugging-utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
5353
utilsToCheckFor: {
5454
type: 'object',
5555
properties: DEBUG_UTILS.reduce<
56-
Record<string, JSONSchema.JSONSchema7>
56+
Record<string, JSONSchema.JSONSchema4>
5757
>(
5858
(obj, name) => ({
5959
[name]: { type: 'boolean' },

lib/rules/no-dom-import.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const DOM_TESTING_LIBRARY_MODULES = [
1313
];
1414

1515
const CORRECT_MODULE_NAME_BY_FRAMEWORK: Record<
16-
'angular' | 'marko' | string,
16+
'angular' | 'marko' | (string & NonNullable<unknown>),
1717
string | undefined
1818
> = {
1919
angular: '@testing-library/angular', // ATL is *always* called `@testing-library/angular`

lib/rules/no-render-in-lifecycle.ts

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
6868
properties: {
6969
allowTestingFrameworkSetupHook: {
7070
enum: TESTING_FRAMEWORK_SETUP_HOOKS,
71+
type: 'string',
7172
},
7273
},
7374
},

lib/rules/prefer-explicit-assert.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ type Options = [
2121

2222
const isAtTopLevel = (node: TSESTree.Node) =>
2323
(!!node.parent?.parent &&
24-
node.parent.parent.type === 'ExpressionStatement') ||
25-
(node.parent?.parent?.type === 'AwaitExpression' &&
24+
node.parent.parent.type === TSESTree.AST_NODE_TYPES.ExpressionStatement) ||
25+
(node.parent?.parent?.type === TSESTree.AST_NODE_TYPES.AwaitExpression &&
2626
!!node.parent.parent.parent &&
27-
node.parent.parent.parent.type === 'ExpressionStatement');
27+
node.parent.parent.parent.type ===
28+
TSESTree.AST_NODE_TYPES.ExpressionStatement);
2829

2930
const isVariableDeclaration = (node: TSESTree.Node) => {
3031
if (

lib/utils/compat.ts

+1-47
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,4 @@
1-
import { type TSESLint, type TSESTree } from '@typescript-eslint/utils';
2-
3-
declare module '@typescript-eslint/utils/dist/ts-eslint/Rule' {
4-
export interface RuleContext<
5-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
6-
TMessageIds extends string,
7-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
8-
TOptions extends readonly unknown[],
9-
> {
10-
/**
11-
* The filename associated with the source.
12-
*/
13-
filename: string;
14-
15-
/**
16-
* A SourceCode object that you can use to work with the source that
17-
* was passed to ESLint.
18-
*/
19-
sourceCode: Readonly<TSESLint.SourceCode>;
20-
}
21-
}
22-
23-
declare module '@typescript-eslint/utils/dist/ts-eslint/SourceCode' {
24-
export interface SourceCode {
25-
/**
26-
* Returns the scope of the given node.
27-
* This information can be used track references to variables.
28-
* @since 8.37.0
29-
*/
30-
getScope(node: TSESTree.Node): TSESLint.Scope.Scope;
31-
/**
32-
* Returns an array of the ancestors of the given node, starting at
33-
* the root of the AST and continuing through the direct parent of the current node.
34-
* This array does not include the currently-traversed node itself.
35-
* @since 8.38.0
36-
*/
37-
getAncestors(node: TSESTree.Node): TSESTree.Node[];
38-
/**
39-
* Returns a list of variables declared by the given node.
40-
* This information can be used to track references to variables.
41-
* @since 8.38.0
42-
*/
43-
getDeclaredVariables(
44-
node: TSESTree.Node
45-
): readonly TSESLint.Scope.Variable[];
46-
}
47-
}
1+
import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
482

493
/* istanbul ignore next */
504
export const getFilename = (

lib/utils/types.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import { type TSESLint } from '@typescript-eslint/utils';
22

3+
type Recommended = 'error' | 'warn' | false;
34
type RecommendedConfig<TOptions extends readonly unknown[]> =
4-
| TSESLint.RuleMetaDataDocs['recommended']
5-
| [TSESLint.RuleMetaDataDocs['recommended'], ...TOptions];
5+
| Recommended
6+
| [Recommended, ...TOptions];
67

7-
// These 2 types are copied from @typescript-eslint/utils' CreateRuleMeta
8+
// These 2 types are copied from `@typescript-eslint/utils`' `CreateRuleMeta`
89
// and modified to our needs
910
export type TestingLibraryRuleMetaDocs<TOptions extends readonly unknown[]> =
1011
Omit<TSESLint.RuleMetaDataDocs, 'recommended' | 'url'> & {
1112
/**
1213
* The recommendation level for the rule on a framework basis.
1314
* Used by the build tools to generate the framework config.
14-
* Set to false to not include it the config
15+
* Set to `false` to not include it the config
1516
*/
1617
recommendedConfig: Record<
1718
SupportedTestingFramework,

0 commit comments

Comments
 (0)