Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow @typescript-eslint v8 #1636

Merged
merged 4 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
'use strict';

const {
version: typescriptESLintPluginVersion,
} = require('@typescript-eslint/eslint-plugin/package.json');
const semver = require('semver');
const globals = require('./src/globals.json');

const typescriptBanTypesRules = () => {
if (semver.major(typescriptESLintPluginVersion) === 8) {
return {
'@typescript-eslint/no-empty-object-type': 'error',
'@typescript-eslint/no-unsafe-function-type': 'error',
'@typescript-eslint/no-wrapper-object-types': 'error',
};
}

return {
'@typescript-eslint/ban-types': 'error',
};
};

module.exports = {
parser: require.resolve('@typescript-eslint/parser'),
extends: [
Expand Down Expand Up @@ -30,7 +48,7 @@ module.exports = {
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/ban-types': 'error',
...typescriptBanTypesRules(),
'@typescript-eslint/consistent-type-imports': [
'error',
{ disallowTypeAnnotations: false, fixStyle: 'inline-type-imports' },
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,23 @@ jobs:
matrix:
node-version: [16.x, 18.x, 20.x, 21.x, 22.x]
eslint-version: [7, 8, 9]
ts-eslint-plugin-version: [6, 7]
ts-eslint-plugin-version: [6, 7, 8]
exclude:
# ts-eslint/plugin@7 doesn't support node@16
- node-version: 16.x
ts-eslint-plugin-version: 7
# ts-eslint/plugin@8 doesn't support node@16
- node-version: 16.x
ts-eslint-plugin-version: 8
# eslint@9 doesn't support node@16
- node-version: 16.x
eslint-version: 9
# ts-eslint/plugin@7 doesn't support eslint@7
- eslint-version: 7
ts-eslint-plugin-version: 7
# ts-eslint/plugin@8 doesn't support eslint@7
- eslint-version: 7
ts-eslint-plugin-version: 8
runs-on: ubuntu-latest

steps:
Expand Down
20 changes: 10 additions & 10 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ if (semver.major(eslintVersion) !== 8) {
config.projects = config.projects.filter(
({ displayName }) => displayName !== 'lint',
);
}

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

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
]
},
"dependencies": {
"@typescript-eslint/utils": "^6.0.0 || ^7.0.0"
"@typescript-eslint/utils": "^6.0.0 || ^7.0.0 || ^8.0.0"
},
"devDependencies": {
"@babel/cli": "^7.4.4",
Expand Down Expand Up @@ -106,7 +106,7 @@
"typescript": "^5.0.4"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0",
"@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0 || ^8.0.0",
"eslint": "^7.0.0 || ^8.0.0 || ^9.0.0",
"jest": "*"
},
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5199,7 +5199,7 @@ __metadata:
ts-node: ^10.2.1
typescript: ^5.0.4
peerDependencies:
"@typescript-eslint/eslint-plugin": ^6.0.0 || ^7.0.0
"@typescript-eslint/eslint-plugin": ^6.0.0 || ^7.0.0 || ^8.0.0
eslint: ^7.0.0 || ^8.0.0 || ^9.0.0
jest: "*"
peerDependenciesMeta:
Expand Down