mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-09-05 07:28:42 +08:00
🐛 Fix(custom): fix an issue eslint not worked as expected
This commit is contained in:
+101
-45
@@ -1,49 +1,65 @@
|
||||
import eslint from '@eslint/js'
|
||||
import standard from '@vue/eslint-config-standard'
|
||||
import js from '@eslint/js'
|
||||
import { defineConfig } from 'eslint/config'
|
||||
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
|
||||
import configPrettier from 'eslint-config-prettier'
|
||||
import jsonc from 'eslint-plugin-jsonc'
|
||||
import pluginPrettier from 'eslint-plugin-prettier/recommended'
|
||||
import simpleImportSort from 'eslint-plugin-simple-import-sort'
|
||||
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
|
||||
import pluginUnicorn from 'eslint-plugin-unicorn'
|
||||
import pluginVue from 'eslint-plugin-vue'
|
||||
import globals from 'globals'
|
||||
import jsoncParser from 'jsonc-eslint-parser'
|
||||
import tseslint from 'typescript-eslint'
|
||||
import vueParser from 'vue-eslint-parser'
|
||||
|
||||
export default defineConfig(
|
||||
{
|
||||
files: ['./src/*.{ts,tsx,cts,mts,js,cjs,mjs}', './scripts/*.{ts,js,mjs}', './test/*.{ts,js,mjs}']
|
||||
ignores: ['**/node_modules/**', '**/out/**', '**/webpack.config.js', 'vitest.workspace.mjs', '**/dist/**'],
|
||||
},
|
||||
{
|
||||
ignores: ['**/node_modules/**', '**/out/**', '**/webpack.config.js', 'vitest.workspace.mjs', '**/dist/**']
|
||||
},
|
||||
eslint.configs.recommended,
|
||||
js.configs.recommended,
|
||||
...pluginVue.configs['flat/recommended'],
|
||||
...tseslint.configs.recommended,
|
||||
...tseslint.configs.stylistic,
|
||||
...pluginVue.configs['flat/recommended'],
|
||||
...standard,
|
||||
eslintPluginPrettierRecommended,
|
||||
{
|
||||
plugins: {
|
||||
'simple-import-sort': simpleImportSort,
|
||||
unicorn: eslintPluginUnicorn
|
||||
files: ['**/*.ts', '**/*.d.ts'],
|
||||
languageOptions: {
|
||||
parser: tseslint.parser,
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 'latest',
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.node,
|
||||
Office: 'readonly',
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'simple-import-sort/imports': 'error',
|
||||
'simple-import-sort/exports': 'error'
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ['**/*.vue'],
|
||||
languageOptions: {
|
||||
parser: vueParser,
|
||||
parserOptions: {
|
||||
warnOnUnsupportedTypeScriptVersion: false
|
||||
parser: tseslint.parser,
|
||||
extraFileExtensions: ['.vue'],
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 'latest',
|
||||
},
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.node,
|
||||
...globals.browser
|
||||
}
|
||||
}
|
||||
Office: 'readonly',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.ts', '**/*.d.ts', '**/*.vue', 'eslint.config.js', 'vite.config.js', 'electron.vite.config.js'],
|
||||
plugins: {
|
||||
'simple-import-sort': simpleImportSort,
|
||||
unicorn: pluginUnicorn,
|
||||
},
|
||||
rules: {
|
||||
'unicorn/prefer-node-protocol': 'error',
|
||||
'unicorn/prefer-module': 'error',
|
||||
'simple-import-sort/imports': 'error',
|
||||
'simple-import-sort/exports': 'error',
|
||||
eqeqeq: 'error',
|
||||
'no-caller': 'error',
|
||||
'no-constant-condition': ['error', { checkLoops: false }],
|
||||
@@ -58,22 +74,18 @@ export default defineConfig(
|
||||
'prefer-const': 'error',
|
||||
'prefer-object-spread': 'error',
|
||||
'unicode-bom': ['error', 'never'],
|
||||
// Enabled in eslint:recommended, but not applicable here
|
||||
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
'no-unused-vars': 'off',
|
||||
'no-extra-boolean-cast': 'off',
|
||||
'no-case-declarations': 'off',
|
||||
'no-cond-assign': 'off',
|
||||
'no-control-regex': 'off',
|
||||
'no-inner-declarations': 'off',
|
||||
'no-empty': 'off',
|
||||
|
||||
// @typescript-eslint/eslint-plugin
|
||||
'no-unused-expressions': 'off',
|
||||
'@typescript-eslint/no-unused-expressions': 'off',
|
||||
'@typescript-eslint/ban-ts-comment': 'off',
|
||||
'@typescript-eslint/class-literal-property-style': 'off',
|
||||
'@typescript-eslint/consistent-indexed-object-style': 'off',
|
||||
'@typescript-eslint/consistent-generic-constructors': 'off',
|
||||
'@typescript-eslint/no-duplicate-enum-values': 'off',
|
||||
'@typescript-eslint/no-empty-function': 'off',
|
||||
'@typescript-eslint/no-namespace': 'off',
|
||||
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
|
||||
@@ -82,12 +94,51 @@ export default defineConfig(
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-empty-object-type': 'off', // {} is a totally useful and valid type.
|
||||
'@typescript-eslint/no-require-imports': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'@typescript-eslint/no-inferrable-types': 'off',
|
||||
'@typescript-eslint/no-this-alias': 'off',
|
||||
// Pending https://github.com/typescript-eslint/typescript-eslint/issues/4820
|
||||
'@typescript-eslint/prefer-optional-chain': 'off',
|
||||
'unicorn/prefer-node-protocol': 'error'
|
||||
}
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'error',
|
||||
{
|
||||
args: 'all',
|
||||
argsIgnorePattern: '^_',
|
||||
caughtErrors: 'all',
|
||||
caughtErrorsIgnorePattern: '^_',
|
||||
},
|
||||
],
|
||||
'vue/no-v-html': 'off',
|
||||
'vue/multi-word-component-names': 'off',
|
||||
'no-undef': 'off', // TypeScript handles this
|
||||
'no-async-promise-executor': 'off',
|
||||
},
|
||||
},
|
||||
...jsonc.configs['flat/recommended-with-jsonc'],
|
||||
{
|
||||
files: ['**/*.json', '**/*.jsonc', '**/*.json5'],
|
||||
languageOptions: {
|
||||
parser: jsoncParser,
|
||||
},
|
||||
rules: {
|
||||
'jsonc/array-bracket-spacing': ['error', 'never'],
|
||||
'jsonc/comma-dangle': ['error', 'never'],
|
||||
'jsonc/indent': ['error', 2],
|
||||
'jsonc/no-comments': 'off',
|
||||
'jsonc/quotes': ['error', 'double'],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['src/renderer/i18n/**/*.json'],
|
||||
rules: {
|
||||
'jsonc/sort-keys': [
|
||||
'error',
|
||||
'asc', // 升序排列
|
||||
{
|
||||
caseSensitive: false,
|
||||
natural: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.mjs', '**/*.mts'],
|
||||
@@ -99,19 +150,24 @@ export default defineConfig(
|
||||
{ name: '__dirname' },
|
||||
{ name: 'require' },
|
||||
{ name: 'module' },
|
||||
{ name: 'exports' }
|
||||
]
|
||||
}
|
||||
{ name: 'exports' },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['*.vue', '**/*.vue'],
|
||||
files: ['*.config.js', '.stylelintrc.cjs', 'scripts/*.{js,mjs,cjs}'],
|
||||
languageOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
globals: globals.browser,
|
||||
parserOptions: {
|
||||
parser: tseslint.parser
|
||||
}
|
||||
}
|
||||
}
|
||||
globals: {
|
||||
...globals.node,
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
// 在脚本文件中,通常允许使用 console 和 require
|
||||
'no-console': 'off',
|
||||
'@typescript-eslint/no-require-imports': 'off',
|
||||
'@typescript-eslint/no-var-requires': 'off',
|
||||
},
|
||||
},
|
||||
configPrettier,
|
||||
pluginPrettier,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user