Skip to content

chore: upgrade eslint #4126

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

Merged
merged 3 commits into from
Aug 30, 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
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

75 changes: 0 additions & 75 deletions .eslintrc.cjs

This file was deleted.

4 changes: 3 additions & 1 deletion @commitlint/cz-commitlint/src/Question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ export default class Question {
}

protected decorateMessage(_answers: Answers): string {
this.beforeQuestionStart && this.beforeQuestionStart(_answers);
if (this.beforeQuestionStart) {
this.beforeQuestionStart(_answers);
}
if (this.question.type === 'input') {
const countLimitMessage = (() => {
const messages = [];
Expand Down
5 changes: 3 additions & 2 deletions @commitlint/load/src/load.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,10 @@ test('does not mutate config module reference', async () => {
};

const configPath = path.join(cwd, file);
const before = JSON.stringify(require(configPath));

const before = readFileSync(configPath, {encoding: 'utf-8'});
await load({rules}, {cwd, file});
const after = JSON.stringify(require(configPath));
const after = readFileSync(configPath, {encoding: 'utf-8'});

expect(after).toBe(before);
});
Expand Down
108 changes: 108 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import jest from 'eslint-plugin-jest';
import _import from 'eslint-plugin-import';
import {fixupPluginRules} from '@eslint/compat';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import js from '@eslint/js';
import {FlatCompat} from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: ['**/lib/', '**/coverage/', '**/node_modules/', '**/fixtures/'],
},
...compat.extends('eslint:recommended', 'prettier'),
{
plugins: {
'@typescript-eslint': typescriptEslint,
jest,
import: fixupPluginRules(_import),
},

languageOptions: {
globals: {
...globals.node,
},

ecmaVersion: 11,
sourceType: 'module',

parserOptions: {
ecmaFeatures: {
jsx: false,
},
},
},

rules: {
'import/first': 'error',
'import/no-absolute-path': 'error',
'import/no-amd': 'error',
'import/no-mutable-exports': 'error',
'import/no-named-default': 'error',
'import/no-self-import': 'error',

'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
},
],
},
},
...compat
.extends(
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier'
)
.map((config) => ({
...config,
files: ['**/*.cts', '**/*.ts'],
})),
{
files: ['**/*.cts', '**/*.ts'],

languageOptions: {
parser: tsParser,
},

rules: {
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'no-empty': 'off',
'no-var': 'off',
},
},
...compat.extends('plugin:jest/recommended').map((config) => ({
...config,
files: ['**/*.test.ts', '**/*.test.js'],
})),
{
files: ['**/*.test.ts', '**/*.test.js'],

rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-var-requires': 'off',
'import/first': 'off',
'import/no-extraneous-dependencies': 'off',
'jest/no-deprecated-functions': 'off',
},
},
];
24 changes: 14 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"docs-dev": "vitepress dev docs",
"docs-build": "vitepress build docs",
"docs-preview": "vitepress preview docs",
"lint": "eslint . --ext .js,.ts",
"lint-fix": "eslint . --ext .js,.ts --fix",
"lint": "eslint",
"lint-fix": "eslint --fix",
"format": "prettier **/*.{ts,js,json,yml,md} --check",
"format-fix": "prettier **/*.{ts,js,json,yml,md} --write",
"publish": "lerna publish --conventional-commits",
Expand Down Expand Up @@ -85,17 +85,21 @@
"email": "[email protected]"
},
"devDependencies": {
"@eslint/compat": "^1.1.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.9.1",
"@lerna/project": "^6.0.0",
"@swc/core": "^1.7.18",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"@swc/core": "^1.7.21",
"@typescript-eslint/eslint-plugin": "^8.3.0",
"@typescript-eslint/parser": "^8.3.0",
"@vitest/coverage-istanbul": "^2.0.5",
"cross-env": "^7.0.3",
"eslint": "^8.46.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-jest": "^28.8.0",
"husky": "^9.0.11",
"eslint": "^9.9.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.8.1",
"globals": "^15.9.0",
"husky": "^9.1.5",
"lerna": "^6.0.0",
"lint-staged": "15.2.9",
"prettier": "^2.8.8",
Expand Down
Loading