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

Lines changed: 2 additions & 13 deletions
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

Lines changed: 3 additions & 5 deletions
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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
},

0 commit comments

Comments
 (0)