Skip to content

Commit fb43171

Browse files
authored
feat: allow @typescript-eslint v8 (#1636)
* feat: allow `@typescript-eslint` v8 * ci: test against `@typescript-eslint/utils` v8 * chore: handle different rule names depending on `@typescript-eslint/eslint-plugin` version * test: only run `unbound-method` cases when using `@typescript-eslint` v7
1 parent 1bc83b9 commit fb43171

File tree

5 files changed

+39
-15
lines changed

5 files changed

+39
-15
lines changed

.eslintrc.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
'use strict';
22

3+
const {
4+
version: typescriptESLintPluginVersion,
5+
} = require('@typescript-eslint/eslint-plugin/package.json');
6+
const semver = require('semver');
37
const globals = require('./src/globals.json');
48

9+
const typescriptBanTypesRules = () => {
10+
if (semver.major(typescriptESLintPluginVersion) === 8) {
11+
return {
12+
'@typescript-eslint/no-empty-object-type': 'error',
13+
'@typescript-eslint/no-unsafe-function-type': 'error',
14+
'@typescript-eslint/no-wrapper-object-types': 'error',
15+
};
16+
}
17+
18+
return {
19+
'@typescript-eslint/ban-types': 'error',
20+
};
21+
};
22+
523
module.exports = {
624
parser: require.resolve('@typescript-eslint/parser'),
725
extends: [
@@ -30,7 +48,7 @@ module.exports = {
3048
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
3149
'@typescript-eslint/no-require-imports': 'error',
3250
'@typescript-eslint/ban-ts-comment': 'error',
33-
'@typescript-eslint/ban-types': 'error',
51+
...typescriptBanTypesRules(),
3452
'@typescript-eslint/consistent-type-imports': [
3553
'error',
3654
{ disallowTypeAnnotations: false, fixStyle: 'inline-type-imports' },

.github/workflows/nodejs.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,23 @@ jobs:
7373
matrix:
7474
node-version: [16.x, 18.x, 20.x, 21.x, 22.x]
7575
eslint-version: [7, 8, 9]
76-
ts-eslint-plugin-version: [6, 7]
76+
ts-eslint-plugin-version: [6, 7, 8]
7777
exclude:
7878
# ts-eslint/plugin@7 doesn't support node@16
7979
- node-version: 16.x
8080
ts-eslint-plugin-version: 7
81+
# ts-eslint/plugin@8 doesn't support node@16
82+
- node-version: 16.x
83+
ts-eslint-plugin-version: 8
8184
# eslint@9 doesn't support node@16
8285
- node-version: 16.x
8386
eslint-version: 9
8487
# ts-eslint/plugin@7 doesn't support eslint@7
8588
- eslint-version: 7
8689
ts-eslint-plugin-version: 7
90+
# ts-eslint/plugin@8 doesn't support eslint@7
91+
- eslint-version: 7
92+
ts-eslint-plugin-version: 8
8793
runs-on: ubuntu-latest
8894

8995
steps:

jest.config.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ if (semver.major(eslintVersion) !== 8) {
4242
config.projects = config.projects.filter(
4343
({ displayName }) => displayName !== 'lint',
4444
);
45+
}
4546

46-
// jest/unbound-method doesn't work when using @typescript-eslint v6
47-
if (semver.major(typescriptESLintPluginVersion) === 6) {
48-
for (const project of config.projects) {
49-
project.testPathIgnorePatterns.push(
50-
'<rootDir>/src/rules/__tests__/unbound-method.test.ts',
51-
);
52-
project.coveragePathIgnorePatterns.push(
53-
'<rootDir>/src/rules/unbound-method.ts',
54-
);
55-
}
47+
// jest/unbound-method seems to only be happy with @typescript-eslint v7 right now...
48+
if (semver.major(typescriptESLintPluginVersion) !== 7) {
49+
for (const project of config.projects) {
50+
project.testPathIgnorePatterns.push(
51+
'<rootDir>/src/rules/__tests__/unbound-method.test.ts',
52+
);
53+
project.coveragePathIgnorePatterns.push(
54+
'<rootDir>/src/rules/unbound-method.ts',
55+
);
5656
}
5757
}
5858

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
]
5959
},
6060
"dependencies": {
61-
"@typescript-eslint/utils": "^6.0.0 || ^7.0.0"
61+
"@typescript-eslint/utils": "^6.0.0 || ^7.0.0 || ^8.0.0"
6262
},
6363
"devDependencies": {
6464
"@babel/cli": "^7.4.4",
@@ -106,7 +106,7 @@
106106
"typescript": "^5.0.4"
107107
},
108108
"peerDependencies": {
109-
"@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0",
109+
"@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0 || ^8.0.0",
110110
"eslint": "^7.0.0 || ^8.0.0 || ^9.0.0",
111111
"jest": "*"
112112
},

yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -5199,7 +5199,7 @@ __metadata:
51995199
ts-node: ^10.2.1
52005200
typescript: ^5.0.4
52015201
peerDependencies:
5202-
"@typescript-eslint/eslint-plugin": ^6.0.0 || ^7.0.0
5202+
"@typescript-eslint/eslint-plugin": ^6.0.0 || ^7.0.0 || ^8.0.0
52035203
eslint: ^7.0.0 || ^8.0.0 || ^9.0.0
52045204
jest: "*"
52055205
peerDependenciesMeta:

0 commit comments

Comments
 (0)