| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import antfu from '@antfu/eslint-config'
- import pluginVitest from '@vitest/eslint-plugin'
- import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
- import pluginPlaywright from 'eslint-plugin-playwright'
- import pluginVue from 'eslint-plugin-vue'
- // To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
- // import { configureVueProject } from '@vue/eslint-config-typescript'
- // configureVueProject({ scriptLangs: ['ts', 'tsx'] })
- // More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup
- export default antfu(
- {
- type: 'app',
- vue: true, // 启用 Vue 支持
- typescript: true, // 启用 TS 支持
- jsonc: true, // 支持 .json/.jsonc
- yaml: true, // 支持 .yaml
- markdown: true, // 支持 .md 中代码块
- unocss: true, // 支持 unocss
- test: true, // 启用 Vitest 支持
- stylistic: {
- indent: 2,
- semi: false,
- quotes: 'single',
- jsx: true,
- },
- ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
- rules: {
- // 禁用规则
- 'perfectionist/sort-imports': 'off',
- 'perfectionist/sort-named-imports': 'off',
- 'perfectionist/sort-named-exports': 'off',
- 'vue/block-order': 'off',
- 'node/prefer-global/process': 'off',
- 'import/consistent-type-specifier-style': 'off',
- 'antfu/top-level-function': 'off',
- 'antfu/if-newline': 'off',
- 'ts/no-use-before-define': 'off',
- 'dot-notation': 'off',
- // 开发期禁用规则
- 'no-console': 'off',
- },
- },
- pluginVue.configs['flat/essential'],
- {
- rules: {
- // ✅ 添加 vue/block-lang 规则
- 'vue/block-lang': [
- 'error',
- {
- script: {
- lang: ['ts', 'tsx'], // ✅ 支持 tsx
- },
- },
- ],
- // 禁用 pluginVue.configs['flat/essential'] 开启的规则
- 'vue/multi-word-component-names': 'off', // 🚫 禁用多单词组件名规则
- },
- },
- // ✅ 测试文件配置
- {
- ...pluginVitest.configs.recommended,
- files: ['src/**/__tests__/*'],
- },
- // ✅ Playwright 配置
- {
- ...pluginPlaywright.configs['flat/recommended'],
- files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}'],
- },
- skipFormatting,
- )
|