- 从服务器拉取完整代码 - 按框架规范整理项目结构 - 配置 Drone CI 测试环境部署 - 包含后端(FastAPI)、前端(Vue3)、管理端 技术栈: Vue3 + TypeScript + FastAPI + MySQL
146 lines
4.1 KiB
JavaScript
146 lines
4.1 KiB
JavaScript
/* eslint-env node */
|
|
module.exports = {
|
|
root: true,
|
|
env: {
|
|
browser: true,
|
|
es2021: true,
|
|
node: true,
|
|
'vue/setup-compiler-macros': true
|
|
},
|
|
extends: [
|
|
'eslint:recommended',
|
|
'@vue/eslint-config-typescript/recommended',
|
|
'@vue/eslint-config-prettier',
|
|
'plugin:vue/vue3-recommended'
|
|
],
|
|
parser: 'vue-eslint-parser',
|
|
parserOptions: {
|
|
ecmaVersion: 'latest',
|
|
sourceType: 'module',
|
|
parser: '@typescript-eslint/parser',
|
|
extraFileExtensions: ['.vue']
|
|
},
|
|
plugins: ['@typescript-eslint'],
|
|
rules: {
|
|
// Vue 相关规则
|
|
'vue/multi-word-component-names': 'off',
|
|
'vue/no-v-html': 'warn',
|
|
'vue/require-default-prop': 'off',
|
|
'vue/require-explicit-emits': 'error',
|
|
'vue/component-definition-name-casing': ['error', 'PascalCase'],
|
|
'vue/component-name-in-template-casing': ['error', 'kebab-case'],
|
|
'vue/custom-event-name-casing': ['error', 'camelCase'],
|
|
'vue/define-macros-order': 'error',
|
|
'vue/html-comment-content-spacing': 'error',
|
|
'vue/no-restricted-v-bind': ['error', '/^v-/'],
|
|
'vue/no-useless-v-bind': 'error',
|
|
'vue/padding-line-between-blocks': 'error',
|
|
'vue/prefer-separate-static-class': 'error',
|
|
|
|
// TypeScript 相关规则
|
|
'@typescript-eslint/no-unused-vars': [
|
|
'error',
|
|
{
|
|
argsIgnorePattern: '^_',
|
|
varsIgnorePattern: '^_'
|
|
}
|
|
],
|
|
'@typescript-eslint/no-explicit-any': 'warn',
|
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
'@typescript-eslint/no-empty-function': 'off',
|
|
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
'@typescript-eslint/prefer-as-const': 'error',
|
|
'@typescript-eslint/no-inferrable-types': 'off',
|
|
|
|
// JavaScript/通用规则
|
|
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
'no-unused-vars': 'off', // 由 @typescript-eslint/no-unused-vars 处理
|
|
'prefer-const': 'error',
|
|
'no-var': 'error',
|
|
'object-shorthand': 'error',
|
|
'prefer-arrow-callback': 'error',
|
|
'prefer-template': 'error',
|
|
'template-curly-spacing': 'error',
|
|
'arrow-spacing': 'error',
|
|
'comma-dangle': ['error', 'never'],
|
|
'quotes': ['error', 'single', { avoidEscape: true }],
|
|
'semi': ['error', 'never'],
|
|
'indent': ['error', 2, { SwitchCase: 1 }],
|
|
'max-len': [
|
|
'error',
|
|
{
|
|
code: 120,
|
|
ignoreUrls: true,
|
|
ignoreStrings: true,
|
|
ignoreTemplateLiterals: true,
|
|
ignoreRegExpLiterals: true
|
|
}
|
|
],
|
|
'space-before-function-paren': [
|
|
'error',
|
|
{
|
|
anonymous: 'always',
|
|
named: 'never',
|
|
asyncArrow: 'always'
|
|
}
|
|
],
|
|
'keyword-spacing': 'error',
|
|
'space-infix-ops': 'error',
|
|
'eol-last': 'error',
|
|
'no-trailing-spaces': 'error',
|
|
'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0 }],
|
|
'padded-blocks': ['error', 'never'],
|
|
'space-in-parens': ['error', 'never'],
|
|
'array-bracket-spacing': ['error', 'never'],
|
|
'object-curly-spacing': ['error', 'always'],
|
|
'computed-property-spacing': ['error', 'never'],
|
|
'comma-spacing': ['error', { before: false, after: true }],
|
|
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
|
|
|
|
// 导入相关规则
|
|
'sort-imports': [
|
|
'error',
|
|
{
|
|
ignoreCase: false,
|
|
ignoreDeclarationSort: true,
|
|
ignoreMemberSort: false,
|
|
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
|
|
allowSeparatedGroups: true
|
|
}
|
|
]
|
|
},
|
|
overrides: [
|
|
{
|
|
files: ['*.vue'],
|
|
rules: {
|
|
'indent': 'off' // Vue 文件的缩进由 vue/html-indent 处理
|
|
}
|
|
},
|
|
{
|
|
files: ['**/__tests__/**/*', '**/*.{test,spec}.*'],
|
|
env: {
|
|
vitest: true
|
|
},
|
|
rules: {
|
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
'no-console': 'off'
|
|
}
|
|
},
|
|
{
|
|
files: ['*.js', '*.cjs'],
|
|
rules: {
|
|
'@typescript-eslint/no-var-requires': 'off'
|
|
}
|
|
}
|
|
],
|
|
ignorePatterns: [
|
|
'dist',
|
|
'node_modules',
|
|
'*.d.ts',
|
|
'coverage',
|
|
'public'
|
|
]
|
|
}
|