Skip to content

Commit 49418a0

Browse files
authored
feat!: upgrade @typescript-eslint/utils to v7 (#66)
* feat!: drop eslint <8.56 support * feat!: remove eslint-compat-utils, remove compatibility codes
1 parent db5641f commit 49418a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1261
-1378
lines changed

.changeset/blue-pianos-drum.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-import-x": minor
3+
---
4+
5+
chore(dep)!: drop eslint <8.56 support

.changeset/chilled-roses-smile.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-import-x": minor
3+
---
4+
5+
feat!: upgrade @typescript-eslint/utils to v7

.eslintrc.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
const eslintPkg = require('eslint/package.json')
2-
const semver = require('semver')
3-
41
/**
52
* @type {import('eslint').Linter.Config}
63
*/
@@ -12,11 +9,9 @@ module.exports = {
129
'plugin:eslint-plugin/recommended',
1310
'plugin:import-x/recommended',
1411
'plugin:n/recommended',
15-
semver.satisfies(eslintPkg.version, '>=8')
16-
? 'plugin:unicorn/recommended'
17-
: undefined,
12+
'plugin:unicorn/recommended',
1813
'plugin:prettier/recommended',
19-
].filter(Boolean),
14+
],
2015
env: {
2116
node: true,
2217
es6: true,

.github/workflows/ci.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ jobs:
1818
- 18
1919
- 20
2020
eslint:
21-
- 7.2
22-
- 7
23-
- 8
21+
- '8.56'
22+
- '8'
2423
runs-on: ${{ matrix.os }}
2524
steps:
2625
- name: Checkout Repo
@@ -60,7 +59,7 @@ jobs:
6059
EFF_NO_LINK_RULES: true
6160
PARSER_NO_WATCH: true
6261
SKIP_YARN_COREPACK_CHECK: 1
63-
if: ${{ matrix.node == 20 && matrix.eslint == 8 }}
62+
if: ${{ matrix.node == 20 }}
6463

6564
- name: Codecov
6665
uses: codecov/codecov-action@v3

package.json

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,12 @@
4545
"watch": "yarn test --watch"
4646
},
4747
"peerDependencies": {
48-
"eslint": "^7.2.0 || ^8 || ^9.0.0-0"
48+
"eslint": "^8.56.0 || ^9.0.0-0"
4949
},
5050
"dependencies": {
51-
"@typescript-eslint/utils": "^5.62.0",
51+
"@typescript-eslint/utils": "^7.4.0",
5252
"debug": "^4.3.4",
5353
"doctrine": "^3.0.0",
54-
"eslint-compat-utils": "^0.5.0",
5554
"eslint-import-resolver-node": "^0.3.9",
5655
"get-tsconfig": "^4.7.3",
5756
"is-glob": "^4.0.3",
@@ -62,33 +61,32 @@
6261
"@1stg/prettier-config": "^4.0.1",
6362
"@1stg/tsconfig": "^2.3.3",
6463
"@angular-eslint/template-parser": "^17.3.0",
65-
"@babel/core": "^7.24.0",
66-
"@babel/eslint-parser": "^7.23.10",
67-
"@babel/plugin-proposal-decorators": "^7.24.0",
68-
"@babel/plugin-proposal-export-default-from": "^7.23.3",
69-
"@babel/preset-env": "^7.24.0",
70-
"@babel/preset-flow": "^7.24.0",
71-
"@babel/preset-react": "^7.23.3",
72-
"@babel/preset-typescript": "^7.23.3",
64+
"@babel/core": "^7.24.3",
65+
"@babel/eslint-parser": "^7.24.1",
66+
"@babel/plugin-proposal-decorators": "^7.24.1",
67+
"@babel/plugin-proposal-export-default-from": "^7.24.1",
68+
"@babel/preset-env": "^7.24.3",
69+
"@babel/preset-flow": "^7.24.1",
70+
"@babel/preset-react": "^7.24.1",
71+
"@babel/preset-typescript": "^7.24.1",
7372
"@babel/register": "^7.23.7",
7473
"@changesets/changelog-github": "^0.5.0",
7574
"@changesets/cli": "^2.27.1",
7675
"@eslint/import-test-order-redirect-scoped": "link:./test/fixtures/order-redirect-scoped",
7776
"@swc-node/jest": "^1.8.0",
78-
"@swc/core": "^1.4.8",
77+
"@swc/core": "^1.4.11",
7978
"@swc/helpers": "^0.5.7",
8079
"@test-scope/some-module": "link:./test/fixtures/symlinked-module",
8180
"@total-typescript/ts-reset": "^0.5.1",
8281
"@types/debug": "^4.1.12",
8382
"@types/doctrine": "^0.0.9",
84-
"@types/eslint": "^8.56.5",
83+
"@types/eslint": "^8.56.6",
8584
"@types/is-glob": "^4.0.4",
8685
"@types/jest": "^29.5.12",
8786
"@types/json-schema": "^7.0.15",
88-
"@types/node": "^20.11.28",
89-
"@typescript-eslint/eslint-plugin": "^5.62.0",
90-
"@typescript-eslint/parser": "^5.62.0",
91-
"@typescript-eslint/typescript-estree": "^5.62.0",
87+
"@types/node": "^20.11.30",
88+
"@typescript-eslint/eslint-plugin": "^7.4.0",
89+
"@typescript-eslint/parser": "^7.4.0",
9290
"@unts/patch-package": "^8.0.0",
9391
"cross-env": "^7.0.3",
9492
"enhanced-resolve": "^5.16.0",
@@ -99,7 +97,7 @@
9997
"eslint-import-resolver-typescript": "^3.6.1",
10098
"eslint-import-resolver-webpack": "^0.13.8",
10199
"eslint-import-test-order-redirect": "link:./test/fixtures/order-redirect",
102-
"eslint-plugin-eslint-plugin": "^5.4.0",
100+
"eslint-plugin-eslint-plugin": "^5.4.1",
103101
"eslint-plugin-import-x": "link:.",
104102
"eslint-plugin-jest": "^27.9.0",
105103
"eslint-plugin-json": "^3.1.0",
@@ -113,7 +111,7 @@
113111
"rimraf": "^5.0.5",
114112
"svelte": "^4.2.12",
115113
"ts-node": "^10.9.2",
116-
"type-fest": "^4.12.0",
117-
"typescript": "~5.1.0"
114+
"type-fest": "^4.14.0",
115+
"typescript": "^5.4.3"
118116
}
119117
}

patches/@typescript-eslint+utils+5.62.0.patch renamed to patches/@typescript-eslint+utils+7.4.0.patch

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
diff --git a/node_modules/@typescript-eslint/utils/dist/ts-eslint/Rule.d.ts b/node_modules/@typescript-eslint/utils/dist/ts-eslint/Rule.d.ts
2-
index 9a3a1fd..c6ed412 100644
2+
index 5ae7288..3d14a45 100644
33
--- a/node_modules/@typescript-eslint/utils/dist/ts-eslint/Rule.d.ts
44
+++ b/node_modules/@typescript-eslint/utils/dist/ts-eslint/Rule.d.ts
5-
@@ -6,6 +6,10 @@ import type { Scope } from './Scope';
6-
import type { SourceCode } from './SourceCode';
7-
export type RuleRecommendation = 'error' | 'strict' | 'warn' | false;
8-
interface RuleMetaDataDocs {
5+
@@ -11,6 +11,10 @@ export interface RuleRecommendationAcrossConfigs<Options extends readonly unknow
6+
strict: Partial<Options>;
7+
}
8+
export interface RuleMetaDataDocs<Options extends readonly unknown[]> {
99
+ /**
1010
+ * The category the rule falls under
1111
+ */
1212
+ category?: string;
1313
/**
1414
* Concise description of the rule
1515
*/
16-
@@ -15,7 +19,7 @@ interface RuleMetaDataDocs {
16+
@@ -20,7 +24,7 @@ export interface RuleMetaDataDocs<Options extends readonly unknown[]> {
1717
* Used by the build tools to generate the recommended and strict configs.
18-
* Set to false to not include it as a recommendation
18+
* Exclude to not include it as a recommendation.
1919
*/
20-
- recommended: 'error' | 'strict' | 'warn' | false;
21-
+ recommended?: 'error' | 'strict' | 'warn' | boolean;
20+
- recommended?: RuleRecommendation | RuleRecommendationAcrossConfigs<Options>;
21+
+ recommended?: RuleRecommendation | RuleRecommendationAcrossConfigs<Options> | boolean;
2222
/**
2323
* The URL of the rule's docs
2424
*/
2525
diff --git a/node_modules/@typescript-eslint/utils/dist/ts-eslint/RuleTester.d.ts b/node_modules/@typescript-eslint/utils/dist/ts-eslint/RuleTester.d.ts
26-
index c8afefe..d629d04 100644
26+
index 38d1f12..bf897a3 100644
2727
--- a/node_modules/@typescript-eslint/utils/dist/ts-eslint/RuleTester.d.ts
2828
+++ b/node_modules/@typescript-eslint/utils/dist/ts-eslint/RuleTester.d.ts
29-
@@ -115,7 +115,7 @@ interface RunTests<TMessageIds extends string, TOptions extends Readonly<unknown
30-
readonly invalid: readonly InvalidTestCase<TMessageIds, TOptions>[];
29+
@@ -113,7 +113,7 @@ interface RunTests<MessageIds extends string, Options extends Readonly<unknown[]
30+
readonly invalid: readonly InvalidTestCase<MessageIds, Options>[];
3131
}
32-
interface RuleTesterConfig extends Linter.Config {
32+
interface RuleTesterConfig extends ClassicConfig.Config {
3333
- readonly parser: string;
3434
+ readonly parser?: string;
3535
readonly parserOptions?: Readonly<ParserOptions>;

src/rules/consistent-type-specifier-style.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { TSESLint, TSESTree } from '@typescript-eslint/utils'
2-
import { getSourceCode } from 'eslint-compat-utils'
32

43
import { createRule } from '../utils'
54

@@ -74,7 +73,7 @@ export = createRule<[Options?], MessageId>({
7473
},
7574
defaultOptions: [],
7675
create(context) {
77-
const sourceCode = getSourceCode(context)
76+
const { sourceCode } = context
7877

7978
if (context.options[0] === 'prefer-inline') {
8079
return {

src/rules/dynamic-import-chunkname.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import vm from 'node:vm'
22

33
import type { TSESTree } from '@typescript-eslint/utils'
4-
import { getSourceCode } from 'eslint-compat-utils'
54

65
import { createRule } from '../utils'
76

@@ -75,7 +74,7 @@ export = createRule<[Options?], MessageId>({
7574
const chunkSubstrRegex = new RegExp(chunkSubstrFormat)
7675

7776
function run(node: TSESTree.Node, arg: TSESTree.Node) {
78-
const sourceCode = getSourceCode(context)
77+
const { sourceCode } = context
7978
const leadingComments = sourceCode.getCommentsBefore(arg)
8079

8180
if ((!leadingComments || leadingComments.length === 0) && !allowEmpty) {

src/rules/extensions.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@ import {
1111
} from '../utils'
1212

1313
const enumValues = {
14-
enum: ['always', 'ignorePackages', 'never'] as const,
14+
type: 'string' as const,
15+
enum: ['always', 'ignorePackages', 'never'],
1516
}
1617

1718
const patternProperties = {
18-
type: 'object',
19+
type: 'object' as const,
1920
patternProperties: { '.*': enumValues },
2021
}
2122

2223
const properties = {
23-
type: 'object',
24+
type: 'object' as const,
2425
properties: {
2526
pattern: patternProperties,
26-
ignorePackages: { type: 'boolean' },
27+
ignorePackages: {
28+
type: 'boolean' as const,
29+
},
2730
},
2831
}
2932

src/rules/first.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { TSESLint, TSESTree } from '@typescript-eslint/utils'
2-
import { getSourceCode } from 'eslint-compat-utils'
32

43
import type { RuleContext } from '../types'
54
import { createRule } from '../utils'
@@ -53,7 +52,7 @@ export = createRule<['absolute-first'?], MessageId>({
5352
}
5453

5554
const absoluteFirst = context.options[0] === 'absolute-first'
56-
const sourceCode = getSourceCode(context)
55+
const { sourceCode } = context
5756
const originSourceCode = sourceCode.getText()
5857

5958
let nonImportCount = 0

0 commit comments

Comments
 (0)