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,
|
||||
|
||||
[
|
||||
eslintPluginImportX.flatConfigs.recommended,
|
||||
{
|
||||
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',
|
||||
'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'],
|
||||
{
|
||||
|
@ -104,6 +104,7 @@
|
||||
"@vant/auto-import-resolver": "^1.3.0",
|
||||
"@vitejs/plugin-vue": "^5.2.3",
|
||||
"@vitejs/plugin-vue-jsx": "^4.1.2",
|
||||
"@vitest/eslint-plugin": "^1.1.38",
|
||||
"@vue/eslint-config-prettier": "^10.2.0",
|
||||
"@vue/eslint-config-typescript": "^14.5.0",
|
||||
"@vue/test-utils": "^2.4.6",
|
||||
|
23
pnpm-lock.yaml
generated
23
pnpm-lock.yaml
generated
@ -194,6 +194,9 @@ importers:
|
||||
'@vitejs/plugin-vue-jsx':
|
||||
specifier: ^4.1.2
|
||||
version: 4.1.2(vite@6.2.4(@types/node@22.13.14)(jiti@2.4.2)(less@4.2.2)(sass-embedded@1.86.0)(terser@5.39.0)(yaml@2.7.1))(vue@3.5.13(typescript@5.8.2))
|
||||
'@vitest/eslint-plugin':
|
||||
specifier: ^1.1.38
|
||||
version: 1.1.38(@typescript-eslint/utils@8.28.0(eslint@9.23.0(jiti@2.4.2))(typescript@5.8.2))(eslint@9.23.0(jiti@2.4.2))(typescript@5.8.2)
|
||||
'@vue/eslint-config-prettier':
|
||||
specifier: ^10.2.0
|
||||
version: 10.2.0(eslint@9.23.0(jiti@2.4.2))(prettier@3.5.3)
|
||||
@ -1701,6 +1704,19 @@ packages:
|
||||
vite: ^6.2.4
|
||||
vue: ^3.2.25
|
||||
|
||||
'@vitest/eslint-plugin@1.1.38':
|
||||
resolution: {integrity: sha512-KcOTZyVz8RiM5HyriiDVrP1CyBGuhRxle+lBsmSs6NTJEO/8dKVAq+f5vQzHj1/Kc7bYXSDO6yBe62Zx0t5iaw==}
|
||||
peerDependencies:
|
||||
'@typescript-eslint/utils': ^8.24.0
|
||||
eslint: '>= 8.57.0'
|
||||
typescript: '>= 5.0.0'
|
||||
vitest: '*'
|
||||
peerDependenciesMeta:
|
||||
typescript:
|
||||
optional: true
|
||||
vitest:
|
||||
optional: true
|
||||
|
||||
'@volar/language-core@2.4.12':
|
||||
resolution: {integrity: sha512-RLrFdXEaQBWfSnYGVxvR2WrO6Bub0unkdHYIdC31HzIEqATIuuhRRzYu76iGPZ6OtA4Au1SnW0ZwIqPP217YhA==}
|
||||
|
||||
@ -6179,6 +6195,13 @@ snapshots:
|
||||
vite: 6.2.4(@types/node@22.13.14)(jiti@2.4.2)(less@4.2.2)(sass-embedded@1.86.0)(terser@5.39.0)(yaml@2.7.1)
|
||||
vue: 3.5.13(typescript@5.8.2)
|
||||
|
||||
'@vitest/eslint-plugin@1.1.38(@typescript-eslint/utils@8.28.0(eslint@9.23.0(jiti@2.4.2))(typescript@5.8.2))(eslint@9.23.0(jiti@2.4.2))(typescript@5.8.2)':
|
||||
dependencies:
|
||||
'@typescript-eslint/utils': 8.28.0(eslint@9.23.0(jiti@2.4.2))(typescript@5.8.2)
|
||||
eslint: 9.23.0(jiti@2.4.2)
|
||||
optionalDependencies:
|
||||
typescript: 5.8.2
|
||||
|
||||
'@volar/language-core@2.4.12':
|
||||
dependencies:
|
||||
'@volar/source-map': 2.4.12
|
||||
|
@ -1,6 +1,9 @@
|
||||
<script lang="ts">
|
||||
<script setup lang="ts">
|
||||
import type { FileUploadState, FileUploadUploaderEvent } from 'primevue/fileupload';
|
||||
|
||||
import TimesIcon from '@primevue/icons/times';
|
||||
import axios from 'axios';
|
||||
|
||||
interface FileExt extends File {
|
||||
objectURL: string;
|
||||
}
|
||||
@ -16,11 +19,6 @@ interface FileUploadInst extends FileUploadState {
|
||||
url: string;
|
||||
}[];
|
||||
}
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import TimesIcon from '@primevue/icons/times';
|
||||
import axios from 'axios';
|
||||
// https://primevue.org/toast/#headless
|
||||
|
||||
const fileUploadRef = useTemplateRef<FileUploadInst>('fileUploadRef');
|
||||
|
@ -1,7 +1,9 @@
|
||||
<script setup lang="tsx">
|
||||
const VITE_BUILD_COMMIT = import.meta.env.VITE_BUILD_COMMIT;
|
||||
import { useHead, useSeoMeta } from '@unhead/vue';
|
||||
import { routes } from 'vue-router/auto-routes';
|
||||
|
||||
const VITE_BUILD_COMMIT = import.meta.env.VITE_BUILD_COMMIT;
|
||||
|
||||
definePage({
|
||||
name: 'Home',
|
||||
meta: {
|
||||
@ -9,7 +11,6 @@ definePage({
|
||||
hidden: true,
|
||||
},
|
||||
});
|
||||
import { useHead, useSeoMeta } from '@unhead/vue';
|
||||
|
||||
useHead({
|
||||
bodyAttrs: { class: { overflow: true } },
|
||||
|
@ -1,7 +1,7 @@
|
||||
// https://github.dev/unocss/unocss/tree/main/examples/vite-vue3
|
||||
|
||||
import { defineConfig, presetAttributify, presetWind3, transformerDirectives, transformerVariantGroup } from 'unocss';
|
||||
import presetAnimations from 'unocss-preset-animations';
|
||||
import { presetAnimations } from 'unocss-preset-animations';
|
||||
// import presetChinese, { chineseTypography } from 'unocss-preset-chinese';
|
||||
import { presetShadcn } from 'unocss-preset-shadcn';
|
||||
|
||||
|
@ -76,7 +76,7 @@ export function viteArchiverPlugin(options: ArchiverOptions = {}): Plugin {
|
||||
}
|
||||
|
||||
// 根据格式确定文件扩展名
|
||||
const fileExtension = format === 'zip' ? 'zip' : format === 'tar' ? 'tar' : 'tar.gz';
|
||||
const fileExtension = format === 'zip' ? 'zip' : (format === 'tar' ? 'tar' : 'tar.gz');
|
||||
const outputFilePath = path.join(outputPath, `${finalFileName}.${fileExtension}`);
|
||||
const output = fs.createWriteStream(outputFilePath);
|
||||
|
||||
|
@ -22,8 +22,8 @@ import Markdown from 'unplugin-vue-markdown/vite';
|
||||
import { getPascalCaseRouteName, VueRouterAutoImports } from 'unplugin-vue-router';
|
||||
import VueRouter from 'unplugin-vue-router/vite';
|
||||
import { createUtils4uAutoImports } from 'utils4u/auto-imports';
|
||||
import { PluginOption } from 'vite';
|
||||
import checker from 'vite-plugin-checker';
|
||||
import { type PluginOption } from 'vite';
|
||||
import { checker } from 'vite-plugin-checker';
|
||||
import { vitePluginFakeServer } from 'vite-plugin-fake-server';
|
||||
import pluginPurgeCss from 'vite-plugin-purgecss-updated-v5';
|
||||
import { viteSingleFile } from 'vite-plugin-singlefile';
|
||||
|
Reference in New Issue
Block a user