Skip to content

Commit d5d572d

Browse files
authored
chore: upgrade eslint (#4126)
* chore: upgrade eslint * chore: update further deps and fix eslint errors * chore: update deps versions
1 parent 413acca commit d5d572d

File tree

7 files changed

+367
-338
lines changed

7 files changed

+367
-338
lines changed

.eslintignore

-4
This file was deleted.

.eslintrc.cjs

-75
This file was deleted.

@commitlint/cz-commitlint/src/Question.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ export default class Question {
187187
}
188188

189189
protected decorateMessage(_answers: Answers): string {
190-
this.beforeQuestionStart && this.beforeQuestionStart(_answers);
190+
if (this.beforeQuestionStart) {
191+
this.beforeQuestionStart(_answers);
192+
}
191193
if (this.question.type === 'input') {
192194
const countLimitMessage = (() => {
193195
const messages = [];

@commitlint/load/src/load.test.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,10 @@ test('does not mutate config module reference', async () => {
493493
};
494494

495495
const configPath = path.join(cwd, file);
496-
const before = JSON.stringify(require(configPath));
496+
497+
const before = readFileSync(configPath, {encoding: 'utf-8'});
497498
await load({rules}, {cwd, file});
498-
const after = JSON.stringify(require(configPath));
499+
const after = readFileSync(configPath, {encoding: 'utf-8'});
499500

500501
expect(after).toBe(before);
501502
});

eslint.config.mjs

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import typescriptEslint from '@typescript-eslint/eslint-plugin';
2+
import jest from 'eslint-plugin-jest';
3+
import _import from 'eslint-plugin-import';
4+
import {fixupPluginRules} from '@eslint/compat';
5+
import globals from 'globals';
6+
import tsParser from '@typescript-eslint/parser';
7+
import path from 'node:path';
8+
import {fileURLToPath} from 'node:url';
9+
import js from '@eslint/js';
10+
import {FlatCompat} from '@eslint/eslintrc';
11+
12+
const __filename = fileURLToPath(import.meta.url);
13+
const __dirname = path.dirname(__filename);
14+
const compat = new FlatCompat({
15+
baseDirectory: __dirname,
16+
recommendedConfig: js.configs.recommended,
17+
allConfig: js.configs.all,
18+
});
19+
20+
export default [
21+
{
22+
ignores: ['**/lib/', '**/coverage/', '**/node_modules/', '**/fixtures/'],
23+
},
24+
...compat.extends('eslint:recommended', 'prettier'),
25+
{
26+
plugins: {
27+
'@typescript-eslint': typescriptEslint,
28+
jest,
29+
import: fixupPluginRules(_import),
30+
},
31+
32+
languageOptions: {
33+
globals: {
34+
...globals.node,
35+
},
36+
37+
ecmaVersion: 11,
38+
sourceType: 'module',
39+
40+
parserOptions: {
41+
ecmaFeatures: {
42+
jsx: false,
43+
},
44+
},
45+
},
46+
47+
rules: {
48+
'import/first': 'error',
49+
'import/no-absolute-path': 'error',
50+
'import/no-amd': 'error',
51+
'import/no-mutable-exports': 'error',
52+
'import/no-named-default': 'error',
53+
'import/no-self-import': 'error',
54+
55+
'import/no-extraneous-dependencies': [
56+
'error',
57+
{
58+
devDependencies: true,
59+
},
60+
],
61+
},
62+
},
63+
...compat
64+
.extends(
65+
'plugin:@typescript-eslint/eslint-recommended',
66+
'plugin:@typescript-eslint/recommended',
67+
'prettier'
68+
)
69+
.map((config) => ({
70+
...config,
71+
files: ['**/*.cts', '**/*.ts'],
72+
})),
73+
{
74+
files: ['**/*.cts', '**/*.ts'],
75+
76+
languageOptions: {
77+
parser: tsParser,
78+
},
79+
80+
rules: {
81+
'@typescript-eslint/no-unused-vars': 'off',
82+
'@typescript-eslint/no-use-before-define': 'off',
83+
'@typescript-eslint/no-explicit-any': 'off',
84+
'@typescript-eslint/explicit-function-return-type': 'off',
85+
'@typescript-eslint/no-var-requires': 'off',
86+
'@typescript-eslint/no-inferrable-types': 'off',
87+
'@typescript-eslint/no-non-null-assertion': 'off',
88+
'@typescript-eslint/triple-slash-reference': 'off',
89+
'no-empty': 'off',
90+
'no-var': 'off',
91+
},
92+
},
93+
...compat.extends('plugin:jest/recommended').map((config) => ({
94+
...config,
95+
files: ['**/*.test.ts', '**/*.test.js'],
96+
})),
97+
{
98+
files: ['**/*.test.ts', '**/*.test.js'],
99+
100+
rules: {
101+
'@typescript-eslint/no-explicit-any': 'off',
102+
'@typescript-eslint/no-var-requires': 'off',
103+
'import/first': 'off',
104+
'import/no-extraneous-dependencies': 'off',
105+
'jest/no-deprecated-functions': 'off',
106+
},
107+
},
108+
];

package.json

+14-10
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"docs-dev": "vitepress dev docs",
1616
"docs-build": "vitepress build docs",
1717
"docs-preview": "vitepress preview docs",
18-
"lint": "eslint . --ext .js,.ts",
19-
"lint-fix": "eslint . --ext .js,.ts --fix",
18+
"lint": "eslint",
19+
"lint-fix": "eslint --fix",
2020
"format": "prettier **/*.{ts,js,json,yml,md} --check",
2121
"format-fix": "prettier **/*.{ts,js,json,yml,md} --write",
2222
"publish": "lerna publish --conventional-commits",
@@ -85,17 +85,21 @@
8585
"email": "[email protected]"
8686
},
8787
"devDependencies": {
88+
"@eslint/compat": "^1.1.1",
89+
"@eslint/eslintrc": "^3.1.0",
90+
"@eslint/js": "^9.9.1",
8891
"@lerna/project": "^6.0.0",
89-
"@swc/core": "^1.7.18",
90-
"@typescript-eslint/eslint-plugin": "^7.0.2",
91-
"@typescript-eslint/parser": "^7.0.2",
92+
"@swc/core": "^1.7.21",
93+
"@typescript-eslint/eslint-plugin": "^8.3.0",
94+
"@typescript-eslint/parser": "^8.3.0",
9295
"@vitest/coverage-istanbul": "^2.0.5",
9396
"cross-env": "^7.0.3",
94-
"eslint": "^8.46.0",
95-
"eslint-config-prettier": "^9.0.0",
96-
"eslint-plugin-import": "^2.28.0",
97-
"eslint-plugin-jest": "^28.8.0",
98-
"husky": "^9.0.11",
97+
"eslint": "^9.9.1",
98+
"eslint-config-prettier": "^9.1.0",
99+
"eslint-plugin-import": "^2.29.1",
100+
"eslint-plugin-jest": "^28.8.1",
101+
"globals": "^15.9.0",
102+
"husky": "^9.1.5",
99103
"lerna": "^6.0.0",
100104
"lint-staged": "15.2.9",
101105
"prettier": "^2.8.8",

0 commit comments

Comments
 (0)