Skip to content

Commit 4ba14da

Browse files
SukkaWmerrywhether
andauthored
refactor!: bump typescript-eslint to v8 (#112)
Co-authored-by: merrywhether <[email protected]> Co-authored-by: Risto Keravuori <[email protected]>
1 parent ea7c13e commit 4ba14da

Some content is hidden

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

60 files changed

+3108
-2295
lines changed

.changeset/smooth-donkeys-drive.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-import-x": major
3+
---
4+
5+
Use typescript-eslint v8. The minimum supported ESLint version is now >= 8.57.0 and the minimum required Node.js version is now 18.18.0.

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = {
2323
},
2424
rules: {
2525
'@typescript-eslint/no-non-null-assertion': 'off',
26-
'@typescript-eslint/no-var-requires': 'off',
26+
'@typescript-eslint/no-require-imports': 'off',
2727

2828
'eslint-plugin/consistent-output': ['error', 'always'],
2929
'eslint-plugin/meta-property-ordering': 'error',

.github/workflows/ci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ jobs:
1414
- ubuntu-latest
1515
# - windows-latest
1616
node:
17-
- 16
1817
- 18
1918
- 20
19+
- 22
2020
eslint:
2121
- '8.56'
2222
- '8'
23+
- '9'
2324
runs-on: ${{ matrix.os }}
2425
steps:
2526
- name: Checkout Repo

package.json

+32-26
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"license": "MIT",
88
"packageManager": "[email protected]",
99
"engines": {
10-
"node": ">=16"
10+
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
1111
},
1212
"main": "lib/index.js",
1313
"exports": {
@@ -35,7 +35,7 @@
3535
"codesandbox:install": "yarn --ignore-engines",
3636
"lint": "run-p lint:*",
3737
"lint:docs": "yarn update:eslint-docs --check",
38-
"lint:es": "eslint . --cache",
38+
"lint:es": "ESLINT_USE_FLAT_CONFIG=false eslint . --cache",
3939
"lint:tsc": "tsc -p tsconfig.base.json --noEmit",
4040
"prepare": "patch-package",
4141
"release": "changeset publish",
@@ -45,57 +45,60 @@
4545
"watch": "yarn test --watch"
4646
},
4747
"peerDependencies": {
48-
"eslint": "^8.56.0 || ^9.0.0-0"
48+
"eslint": "^8.57.0 || ^9.0.0"
4949
},
5050
"dependencies": {
51-
"@typescript-eslint/utils": "^7.4.0",
51+
"@typescript-eslint/utils": "^8.1.0",
5252
"debug": "^4.3.4",
5353
"doctrine": "^3.0.0",
5454
"eslint-import-resolver-node": "^0.3.9",
5555
"get-tsconfig": "^4.7.3",
5656
"is-glob": "^4.0.3",
5757
"minimatch": "^9.0.3",
58-
"semver": "^7.6.0",
58+
"semver": "^7.6.3",
5959
"stable-hash": "^0.0.4",
60-
"tslib": "^2.6.2"
60+
"tslib": "^2.6.3"
6161
},
6262
"devDependencies": {
6363
"@1stg/prettier-config": "^4.0.1",
6464
"@1stg/tsconfig": "^2.3.3",
65-
"@angular-eslint/template-parser": "^17.3.0",
66-
"@babel/core": "^7.24.3",
67-
"@babel/eslint-parser": "^7.24.1",
68-
"@babel/plugin-proposal-decorators": "^7.24.1",
69-
"@babel/plugin-proposal-export-default-from": "^7.24.1",
70-
"@babel/preset-env": "^7.24.3",
71-
"@babel/preset-flow": "^7.24.1",
72-
"@babel/preset-react": "^7.24.1",
73-
"@babel/preset-typescript": "^7.24.1",
74-
"@babel/register": "^7.23.7",
65+
"@angular-eslint/template-parser": "^17.5.2",
66+
"@babel/core": "^7.25.2",
67+
"@babel/eslint-parser": "^7.25.1",
68+
"@babel/plugin-proposal-decorators": "^7.24.7",
69+
"@babel/plugin-proposal-export-default-from": "^7.24.7",
70+
"@babel/preset-env": "^7.25.3",
71+
"@babel/preset-flow": "^7.24.7",
72+
"@babel/preset-react": "^7.24.7",
73+
"@babel/preset-typescript": "^7.24.7",
74+
"@babel/register": "^7.24.6",
7575
"@changesets/changelog-github": "^0.5.0",
7676
"@changesets/cli": "^2.27.1",
7777
"@eslint/import-test-order-redirect-scoped": "link:./test/fixtures/order-redirect-scoped",
78-
"@swc-node/jest": "^1.8.0",
79-
"@swc/core": "^1.4.11",
80-
"@swc/helpers": "^0.5.7",
78+
"@swc-node/jest": "^1.8.12",
79+
"@swc/core": "^1.7.6",
80+
"@swc/helpers": "^0.5.12",
8181
"@test-scope/some-module": "link:./test/fixtures/symlinked-module",
8282
"@total-typescript/ts-reset": "^0.5.1",
8383
"@types/debug": "^4.1.12",
8484
"@types/doctrine": "^0.0.9",
85-
"@types/eslint": "^8.56.6",
85+
"@types/eslint": "^9.6.0",
86+
"@types/eslint8.56": "npm:@types/eslint@^8.56.11",
87+
"@types/eslint9": "npm:@types/eslint@^9.6.0",
8688
"@types/is-glob": "^4.0.4",
8789
"@types/jest": "^29.5.12",
8890
"@types/json-schema": "^7.0.15",
8991
"@types/node": "^20.11.30",
90-
"@typescript-eslint/eslint-plugin": "^7.4.0",
91-
"@typescript-eslint/parser": "^7.4.0",
92+
"@typescript-eslint/eslint-plugin": "^8.1.0",
93+
"@typescript-eslint/parser": "^8.1.0",
94+
"@typescript-eslint/rule-tester": "^8.1.0",
9295
"@unts/patch-package": "^8.0.0",
9396
"cross-env": "^7.0.3",
9497
"enhanced-resolve": "^5.16.0",
9598
"escope": "^4.0.0",
96-
"eslint": "^7.2.0 || ^8",
99+
"eslint": "^9.9.0",
97100
"eslint-config-prettier": "^9.1.0",
98-
"eslint-doc-generator": "^1.7.0",
101+
"eslint-doc-generator": "^1.7.1",
99102
"eslint-import-resolver-typescript": "^3.6.1",
100103
"eslint-import-resolver-webpack": "^0.13.8",
101104
"eslint-import-test-order-redirect": "link:./test/fixtures/order-redirect",
@@ -106,14 +109,17 @@
106109
"eslint-plugin-n": "^16.6.2",
107110
"eslint-plugin-prettier": "^5.1.3",
108111
"eslint-plugin-unicorn": "^51.0.1",
112+
"eslint8.56": "npm:eslint@^8.56.0",
113+
"eslint9": "npm:eslint@^9.8.0",
114+
"hermes-eslint": "^0.23.1",
109115
"jest": "^29.7.0",
110116
"npm-run-all2": "^6.1.2",
111117
"prettier": "^3.2.5",
112118
"redux": "^5.0.1",
113-
"rimraf": "^5.0.5",
119+
"rimraf": "^5.0.10",
114120
"svelte": "^4.2.12",
115121
"ts-node": "^10.9.2",
116122
"type-fest": "^4.14.0",
117-
"typescript": "^5.4.3"
123+
"typescript": "^5.5.4"
118124
}
119125
}

patches/@typescript-eslint+utils+7.4.0.patch

-37
This file was deleted.

src/config/react.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ export = {
1111
settings: {
1212
'import-x/extensions': ['.js', '.jsx'],
1313
},
14-
parserOptions: {
15-
ecmaFeatures: {
16-
jsx: true,
14+
languageOptions: {
15+
parserOptions: {
16+
ecmaFeatures: {
17+
jsx: true,
18+
},
1719
},
1820
},
1921
} satisfies PluginConfig

src/rules/dynamic-import-chunkname.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import vm from 'node:vm'
22

33
import type { TSESTree } from '@typescript-eslint/utils'
4-
import type { RuleFixer } from '@typescript-eslint/utils/dist/ts-eslint'
4+
import type { RuleFixer } from '@typescript-eslint/utils/ts-eslint'
55

66
import { createRule } from '../utils'
77

src/rules/imports-first.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
import { ESLintUtils } from '@typescript-eslint/utils'
2-
3-
import { docsUrl } from '../utils/docs-url'
1+
import { createRule } from '../utils'
42

53
import first from './first'
64

7-
const createRule = ESLintUtils.RuleCreator(ruleName =>
8-
docsUrl(ruleName, '7b25c1cb95ee18acc1531002fd343e1e6031f9ed'),
9-
)
10-
115
export = createRule({
126
...first,
137
name: 'imports-first',

src/types.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { TSESLint, TSESTree } from '@typescript-eslint/utils'
22
import type { ResolveOptions } from 'enhanced-resolve'
3-
import type { TsResolverOptions } from 'eslint-import-resolver-typescript'
43
import type { MinimatchOptions } from 'minimatch'
54
import type { KebabCase, LiteralUnion } from 'type-fest'
65

@@ -21,6 +20,12 @@ export type WebpackResolverOptions = {
2120
argv?: Record<string, unknown>
2221
}
2322

23+
export type TsResolverOptions = {
24+
alwaysTryTypes?: boolean
25+
project?: string[] | string
26+
extensions?: string[]
27+
} & Omit<ResolveOptions, 'fileSystem' | 'useSyncFileSystemCalls'>
28+
2429
export type FileExtension = `.${string}`
2530

2631
export type DocStyle = 'jsdoc' | 'tomdoc'
@@ -63,7 +68,7 @@ export type PluginConfig = {
6368
plugins?: [PluginName]
6469
settings?: PluginSettings
6570
rules?: Record<`${PluginName}/${string}`, TSESLint.Linter.RuleEntry>
66-
} & TSESLint.Linter.Config
71+
} & TSESLint.Linter.ConfigType
6772

6873
export type RuleContext<
6974
TMessageIds extends string = string,
@@ -89,11 +94,10 @@ export type ParseError = {
8994
column: number
9095
} & Error
9196

92-
// eslint-disable-next-line @typescript-eslint/ban-types
93-
export type CustomESTreeNode<Type extends string, T extends object = {}> = Omit<
94-
TSESTree.BaseNode,
95-
'type'
96-
> & {
97+
export type CustomESTreeNode<
98+
Type extends string,
99+
T extends object = object,
100+
> = Omit<TSESTree.BaseNode, 'type'> & {
97101
type: Type
98102
} & T
99103

src/utils/create-rule.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,13 @@ import { ESLintUtils } from '@typescript-eslint/utils'
22

33
import { docsUrl } from './docs-url'
44

5-
export const createRule = ESLintUtils.RuleCreator(docsUrl)
5+
type ImportXPluginDocs = {
6+
/**
7+
* The category the rule falls under
8+
*/
9+
category?: string
10+
11+
recommended?: true
12+
}
13+
14+
export const createRule = ESLintUtils.RuleCreator<ImportXPluginDocs>(docsUrl)

src/utils/parse.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import { moduleRequire } from './module-require'
1515
const log = debug('eslint-plugin-import-x:parse')
1616

1717
function keysFromParser(
18-
parserPath: string | TSESLint.Linter.ParserModule,
19-
parserInstance: TSESLint.Linter.ParserModule,
20-
parsedResult?: TSESLint.Linter.ESLintParseResult,
18+
parserPath: string | TSESLint.Parser.ParserModule,
19+
parserInstance: TSESLint.Parser.ParserModule,
20+
parsedResult?: TSESLint.Parser.ParseResult,
2121
) {
2222
// Exposed by @typescript-eslint/parser and @babel/eslint-parser
2323
if (parsedResult && parsedResult.visitorKeys) {
@@ -130,6 +130,7 @@ export function parse(
130130
console.warn(
131131
// Can only be invalid for custom parser per imports/parser
132132
`\`parseForESLint\` from parser \`${typeof parserOrPath === 'string' ? parserOrPath : '`context.languageOptions.parser`'}\` is invalid and will just be ignored`,
133+
{ content, parserMeta: parser.meta },
133134
)
134135
} else {
135136
return makeParseReturn(ast, keysFromParser(parserOrPath, parser))

test/cli.spec.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@
44

55
import path from 'node:path'
66

7-
import { ESLint } from 'eslint'
87
import eslintPkg from 'eslint/package.json'
8+
import { LegacyESLint } from 'eslint/use-at-your-own-risk'
99
import semver from 'semver'
1010

1111
import importPlugin from 'eslint-plugin-import-x'
1212

1313
describe('CLI regression tests', () => {
1414
describe('issue #210', () => {
1515
it("doesn't throw an error on gratuitous, erroneous self-reference", () => {
16-
const eslint = new ESLint({
17-
useEslintrc: false,
16+
const eslint = new LegacyESLint({
1817
overrideConfigFile: './test/fixtures/issue210.config.js',
19-
rulePaths: ['./src/rules'],
18+
// rulePaths: ['./src/rules'],
2019
overrideConfig: {
2120
rules: {
2221
named: 2,
@@ -34,10 +33,8 @@ describe('CLI regression tests', () => {
3433
describe('issue #1645', () => {
3534
it('throws an error on invalid JSON', async () => {
3635
const invalidJSON = './test/fixtures/just-json-files/invalid.json'
37-
const eslint = new ESLint({
38-
useEslintrc: false,
36+
const eslint = new LegacyESLint({
3937
overrideConfigFile: './test/fixtures/just-json-files/.eslintrc.json',
40-
rulePaths: ['./src/rules'],
4138
ignore: false,
4239
plugins: {
4340
// @ts-expect-error - incompatible types
@@ -58,6 +55,7 @@ describe('CLI regression tests', () => {
5855
nodeType: results[0].messages[0].nodeType, // we don't care about this one
5956
ruleId: 'json/*',
6057
severity: 2,
58+
// @ts-expect-error - legacy types
6159
source: results[0].messages[0].source, // NewLine-characters might differ depending on git-settings
6260
},
6361
],

0 commit comments

Comments
 (0)