chore: 统一并强化ESLint配置规则
This commit is contained in:
@@ -10,38 +10,32 @@ export default [
|
|||||||
parser: tseslint.parser,
|
parser: tseslint.parser,
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
ecmaVersion: 2020,
|
ecmaVersion: 2020,
|
||||||
sourceType: 'module'
|
sourceType: 'module',
|
||||||
|
project: true,
|
||||||
|
tsconfigRootDir: import.meta.dirname
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
'semi': 'warn',
|
'semi': ['error', 'always'],
|
||||||
'quotes': 'warn',
|
'quotes': ['error', 'single', { avoidEscape: true }],
|
||||||
'indent': 'off',
|
'indent': ['error', 4, { SwitchCase: 1 }],
|
||||||
'no-trailing-spaces': 'warn',
|
'no-trailing-spaces': 'error',
|
||||||
'eol-last': 'warn',
|
'eol-last': ['error', 'always'],
|
||||||
'comma-dangle': 'warn',
|
'comma-dangle': ['error', 'never'],
|
||||||
'object-curly-spacing': 'warn',
|
'object-curly-spacing': ['error', 'always'],
|
||||||
'array-bracket-spacing': 'warn',
|
'array-bracket-spacing': ['error', 'never'],
|
||||||
'arrow-parens': 'warn',
|
'arrow-parens': ['error', 'always'],
|
||||||
'prefer-const': 'warn',
|
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }],
|
||||||
'no-multiple-empty-lines': 'warn',
|
|
||||||
'no-console': 'off',
|
'no-console': 'off',
|
||||||
'@typescript-eslint/no-explicit-any': 'warn',
|
'@typescript-eslint/no-explicit-any': 'error',
|
||||||
'@typescript-eslint/no-unsafe-function-type': 'warn',
|
'@typescript-eslint/no-unsafe-assignment': 'warn',
|
||||||
'@typescript-eslint/no-unsafe-assignment': 'off',
|
'@typescript-eslint/no-unsafe-member-access': 'warn',
|
||||||
'@typescript-eslint/no-unsafe-member-access': 'off',
|
'@typescript-eslint/no-unsafe-call': 'warn',
|
||||||
'@typescript-eslint/no-unsafe-call': 'off',
|
'@typescript-eslint/no-unsafe-return': 'warn',
|
||||||
'@typescript-eslint/no-unsafe-return': 'off',
|
'@typescript-eslint/no-unsafe-argument': 'warn',
|
||||||
'@typescript-eslint/no-unsafe-argument': 'off',
|
|
||||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||||
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
||||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
'@typescript-eslint/no-non-null-assertion': 'off'
|
||||||
'@typescript-eslint/no-require-imports': 'warn',
|
|
||||||
'@typescript-eslint/no-this-alias': 'warn',
|
|
||||||
'no-case-declarations': 'warn',
|
|
||||||
'no-prototype-builtins': 'warn',
|
|
||||||
'no-empty': 'warn',
|
|
||||||
'no-useless-catch': 'warn'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
import eslint from '@eslint/js';
|
|
||||||
import tseslint from 'typescript-eslint';
|
|
||||||
|
|
||||||
export default [
|
|
||||||
eslint.configs.recommended,
|
|
||||||
...tseslint.configs.recommended,
|
|
||||||
{
|
|
||||||
files: ['src/**/*.{ts,tsx}'],
|
|
||||||
languageOptions: {
|
|
||||||
parser: tseslint.parser,
|
|
||||||
parserOptions: {
|
|
||||||
ecmaVersion: 2020,
|
|
||||||
sourceType: 'module',
|
|
||||||
project: './tsconfig.json'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
'semi': ['error', 'always'],
|
|
||||||
'quotes': ['error', 'single', { avoidEscape: true }],
|
|
||||||
'indent': ['error', 4, { SwitchCase: 1 }],
|
|
||||||
'no-trailing-spaces': 'error',
|
|
||||||
'eol-last': ['error', 'always'],
|
|
||||||
'comma-dangle': ['error', 'never'],
|
|
||||||
'object-curly-spacing': ['error', 'always'],
|
|
||||||
'array-bracket-spacing': ['error', 'never'],
|
|
||||||
'arrow-parens': ['error', 'always'],
|
|
||||||
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }],
|
|
||||||
'no-console': 'off',
|
|
||||||
'@typescript-eslint/no-explicit-any': 'error',
|
|
||||||
'@typescript-eslint/no-unsafe-assignment': 'warn',
|
|
||||||
'@typescript-eslint/no-unsafe-member-access': 'warn',
|
|
||||||
'@typescript-eslint/no-unsafe-call': 'warn',
|
|
||||||
'@typescript-eslint/no-unsafe-return': 'warn',
|
|
||||||
'@typescript-eslint/no-unsafe-argument': 'warn',
|
|
||||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
||||||
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
|
||||||
'@typescript-eslint/no-non-null-assertion': 'off'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ignores: [
|
|
||||||
'node_modules/**',
|
|
||||||
'dist/**',
|
|
||||||
'bin/**',
|
|
||||||
'coverage/**',
|
|
||||||
'**/*.min.js',
|
|
||||||
'**/*.d.ts'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
];
|
|
||||||
@@ -35,7 +35,9 @@
|
|||||||
"build:npm": "npm run build && node build-rollup.cjs",
|
"build:npm": "npm run build && node build-rollup.cjs",
|
||||||
"test": "jest --config jest.config.cjs",
|
"test": "jest --config jest.config.cjs",
|
||||||
"test:watch": "jest --watch --config jest.config.cjs",
|
"test:watch": "jest --watch --config jest.config.cjs",
|
||||||
"test:coverage": "jest --coverage --config jest.config.cjs"
|
"test:coverage": "jest --coverage --config jest.config.cjs",
|
||||||
|
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
||||||
|
"lint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix"
|
||||||
},
|
},
|
||||||
"author": "yhh",
|
"author": "yhh",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -50,6 +52,9 @@
|
|||||||
"@rollup/plugin-terser": "^0.4.4",
|
"@rollup/plugin-terser": "^0.4.4",
|
||||||
"@types/jest": "^29.5.14",
|
"@types/jest": "^29.5.14",
|
||||||
"@types/node": "^20.19.17",
|
"@types/node": "^20.19.17",
|
||||||
|
"@eslint/js": "^9.37.0",
|
||||||
|
"eslint": "^9.37.0",
|
||||||
|
"typescript-eslint": "^8.46.1",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"rimraf": "^5.0.0",
|
"rimraf": "^5.0.0",
|
||||||
"rollup": "^4.42.0",
|
"rollup": "^4.42.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user