feat: 更新 ESLint 配置
This commit is contained in:
@ -1,40 +1,58 @@
|
||||
import { includeIgnoreFile } from '@eslint/compat';
|
||||
/*
|
||||
MORE:
|
||||
https://juejin.cn/post/7403244457263628300#heading-11
|
||||
*/
|
||||
import pluginVitest from '@vitest/eslint-plugin';
|
||||
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting';
|
||||
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript';
|
||||
import pluginImport from 'eslint-plugin-import-x';
|
||||
import { configureVueProject, defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript';
|
||||
import eslintPluginImportX from 'eslint-plugin-import-x';
|
||||
import oxlint from 'eslint-plugin-oxlint';
|
||||
import perfectionist from 'eslint-plugin-perfectionist';
|
||||
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
|
||||
import pluginVue from 'eslint-plugin-vue';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
|
||||
import { configureVueProject } from '@vue/eslint-config-typescript';
|
||||
|
||||
// https://github.com/vuejs/eslint-config-typescript/#advanced-setup
|
||||
configureVueProject({ scriptLangs: ['ts', 'tsx', 'js', 'jsx'] });
|
||||
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup
|
||||
|
||||
const _ignores = [
|
||||
// eslint-disable-next-line unicorn/no-await-expression-member
|
||||
(await import('@eslint/compat')).includeIgnoreFile(
|
||||
// eslint-disable-next-line unicorn/import-style, unicorn/no-await-expression-member
|
||||
(await import('node:path')).default.resolve(import.meta.dirname, '.gitignore'),
|
||||
),
|
||||
|
||||
// eslint-disable-next-line unicorn/no-await-expression-member
|
||||
(await import('eslint/config')).globalIgnores([
|
||||
'**/dist/**',
|
||||
'**/dist-ssr/**',
|
||||
'**/coverage/**',
|
||||
'auto-imports.d.ts',
|
||||
'components.d.ts',
|
||||
'typed-router.d.ts',
|
||||
'src/shadcn/**',
|
||||
'src/components/InspiraUI/**',
|
||||
]),
|
||||
];
|
||||
|
||||
export default defineConfigWithVueTs(
|
||||
includeIgnoreFile(path.resolve(__dirname, '.gitignore')),
|
||||
{ ignores: ['typed-router.d.ts', 'src/shadcn/**', 'src/components/InspiraUI/**'] },
|
||||
|
||||
{
|
||||
files: ['**/*.{ts,mts,tsx,vue}'],
|
||||
name: 'app/files-to-lint',
|
||||
files: ['**/*.{ts,mts,tsx,vue}'],
|
||||
},
|
||||
|
||||
{
|
||||
ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
|
||||
name: 'app/files-to-ignore',
|
||||
},
|
||||
_ignores,
|
||||
|
||||
pluginVue.configs['flat/essential'],
|
||||
vueTsConfigs.recommended,
|
||||
|
||||
{
|
||||
...pluginVitest.configs.recommended,
|
||||
files: ['src/**/__tests__/*'],
|
||||
},
|
||||
|
||||
...oxlint.configs['flat/recommended'],
|
||||
skipFormatting,
|
||||
|
||||
eslintPluginUnicorn.configs.recommended,
|
||||
{
|
||||
rules: {
|
||||
@ -46,35 +64,14 @@ export default defineConfigWithVueTs(
|
||||
},
|
||||
},
|
||||
|
||||
// {
|
||||
// ...pluginVitest.configs.recommended,
|
||||
// files: ['src/**/__tests__/*'],
|
||||
// },
|
||||
|
||||
// {
|
||||
// ...pluginCypress.configs.recommended,
|
||||
// files: ['cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}', 'cypress/support/**/*.{js,ts,jsx,tsx}'],
|
||||
// },
|
||||
...oxlint.configs['flat/recommended'],
|
||||
skipFormatting,
|
||||
|
||||
[
|
||||
{
|
||||
plugins: {
|
||||
import: pluginImport,
|
||||
},
|
||||
rules: {
|
||||
// 'import/first': 'error',
|
||||
'import/newline-after-import': 'error',
|
||||
// 'import/no-duplicates': 'error',
|
||||
// 'import/no-mutable-exports': 'error',
|
||||
// 'import/no-named-default': 'error',
|
||||
// 'import/no-self-import': 'error',
|
||||
// 'import/no-unresolved': 'off',
|
||||
// 'import/no-webpack-loader-syntax': 'error',
|
||||
},
|
||||
eslintPluginImportX.flatConfigs.recommended,
|
||||
{
|
||||
rules: {
|
||||
'import-x/no-unresolved': 'off',
|
||||
'import-x/newline-after-import': 'error',
|
||||
'import-x/first': 'error',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
rules: {
|
||||
@ -96,7 +93,6 @@ export default defineConfigWithVueTs(
|
||||
},
|
||||
|
||||
// https://perfectionist.dev/guide/getting-started
|
||||
|
||||
[
|
||||
perfectionist.configs['recommended-natural'],
|
||||
{
|
||||
|
Reference in New Issue
Block a user