chore: upgrade ESLint 9

This commit is contained in:
三咲智子 Kevin Deng 2024-05-25 14:02:07 +08:00
parent 261d63f683
commit dabd9947bf
No known key found for this signature in database
6 changed files with 1165 additions and 825 deletions

View File

@ -1,3 +0,0 @@
dist
coverage
node_modules

View File

@ -1,60 +0,0 @@
const { builtinModules } = require('node:module');
module.exports = {
root: true,
env: {
browser: true,
node: true,
es6: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
],
plugins: ['import'],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
rules: {
eqeqeq: ['warn', 'always', { null: 'never' }],
'no-debugger': ['error'],
'no-empty': ['warn', { allowEmptyCatch: true }],
'prefer-const': [
'warn',
{
destructuring: 'all',
},
],
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports', fixStyle: 'inline-type-imports' },
],
'import/no-nodejs-modules': [
'error',
{ allow: builtinModules.map((mod) => `node:${mod}`) },
],
'import/no-duplicates': 'error',
'import/order': 'error',
'sort-imports': [
'error',
{
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: false,
},
],
},
};

69
eslint.config.js Normal file
View File

@ -0,0 +1,69 @@
// @ts-check
import { builtinModules } from 'node:module';
import tseslint from 'typescript-eslint';
import importX from 'eslint-plugin-import-x';
// @ts-expect-error missing types
import eslint from '@eslint/js';
// @ts-expect-error missing types
import eslintConfigPrettier from 'eslint-config-prettier';
export default tseslint.config(
eslint.configs.recommended,
{
files: ['**/*.js', '**/*.ts', '**/*.tsx'],
extends: [...tseslint.configs.recommended],
plugins: {
import: importX,
},
languageOptions: {
parserOptions: {
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
},
rules: {
eqeqeq: ['warn', 'always', { null: 'never' }],
'no-debugger': ['error'],
'no-empty': ['warn', { allowEmptyCatch: true }],
'prefer-const': [
'warn',
{
destructuring: 'all',
},
],
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports', fixStyle: 'inline-type-imports' },
],
'import/no-nodejs-modules': [
'error',
{ allow: builtinModules.map((mod) => `node:${mod}`) },
],
'import/no-duplicates': 'error',
'import/order': 'error',
'sort-imports': [
'error',
{
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: false,
},
],
},
},
eslintConfigPrettier,
{
ignores: ['**/dist/', '**/coverage/'],
}
);

View File

@ -20,22 +20,24 @@
], ],
"devDependencies": { "devDependencies": {
"@babel/plugin-syntax-typescript": "^7.23.3", "@babel/plugin-syntax-typescript": "^7.23.3",
"@eslint/js": "^9.3.0",
"@rollup/plugin-babel": "^6.0.4", "@rollup/plugin-babel": "^6.0.4",
"@types/babel__core": "^7.20.5", "@types/babel__core": "^7.20.5",
"@types/babel__helper-module-imports": "^7.18.3", "@types/babel__helper-module-imports": "^7.18.3",
"@types/babel__helper-plugin-utils": "^7.10.3", "@types/babel__helper-plugin-utils": "^7.10.3",
"@types/node": "^20.11.16", "@types/node": "^20.11.16",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@vitest/coverage-v8": "^1.2.2", "@vitest/coverage-v8": "^1.2.2",
"@vue/babel-plugin-jsx": "workspace:*", "@vue/babel-plugin-jsx": "workspace:*",
"bumpp": "^9.3.0", "bumpp": "^9.3.0",
"eslint": "^8.56.0", "eslint": "^9.3.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1", "eslint-plugin-import-x": "^0.5.0",
"jsdom": "^24.0.0", "jsdom": "^24.0.0",
"prettier": "^3.2.5", "prettier": "^3.2.5",
"tslib": "^2.6.2",
"tsup": "^8.0.1", "tsup": "^8.0.1",
"typescript": "^5.3.3", "typescript": "^5.3.3",
"typescript-eslint": "^7.10.0",
"vite": "^5.0.12", "vite": "^5.0.12",
"vitest": "^1.2.2" "vitest": "^1.2.2"
} }

View File

@ -482,11 +482,8 @@ test('reassign variable as component should work', () => {
}, },
}); });
/* eslint-disable */
const _a2 = 2; const _a2 = 2;
a = _a2; a = _a2;
/* eslint-enable */
a = <A>{a}</A>; a = <A>{a}</A>;
const wrapper = mount({ const wrapper = mount({

File diff suppressed because it is too large Load Diff