feat: 合同文档模板设置

This commit is contained in:
Zzz1zz
2025-10-12 15:08:29 +08:00
parent fc07ed06d5
commit 8e43e1835f
38 changed files with 4560 additions and 1410 deletions
+99 -47
View File
@@ -1,77 +1,129 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');
module.exports = {
root: true,
parser: 'vue-eslint-parser',
parserOptions: {
// Parser that checks the content of the <script> tag
parser: '@typescript-eslint/parser',
sourceType: 'module',
ecmaVersion: 2020,
ecmaFeatures: {
jsx: true,
},
},
env: {
'browser': true,
'node': true,
'es2021': true,
'vue/setup-compiler-macros': true,
},
plugins: ['@typescript-eslint'],
// 1. 主解析器始终是 'vue-eslint-parser'
parser: 'vue-eslint-parser',
parserOptions: {
// 2. 在顶层 parserOptions 中指定 TS 解析器和 JSX 支持
parser: '@typescript-eslint/parser',
ecmaVersion: 'latest', // 使用 'latest' 更稳妥
sourceType: 'module',
ecmaFeatures: {
jsx: true, // 关键:开启 JSX 支持
},
extraFileExtensions: ['.vue'],
project: path.resolve(__dirname, './tsconfig.json'),
},
extends: [
// Airbnb JavaScript Style Guide https://github.com/airbnb/javascript
'airbnb-base',
'plugin:vue/vue3-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:vue/vue3-recommended',
'plugin:prettier/recommended',
],
settings: {
'import/resolver': {
typescript: {
project: path.resolve(__dirname, './tsconfig.json'),
},
},
},
plugins: ['vue', '@typescript-eslint', 'import', 'prettier'],
rules: {
// 你的规则保持不变
'no-param-reassign': 0,
'no-plusplus': 0,
'prettier/prettier': 1,
// Vue: Recommended rules to be closed or modify
'no-console': process.env.NODE_ENV === 'production' ? 2 : 1,
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'no-unused-expressions': 'off',
'vue/multi-word-component-names': 0,
'vue/require-default-prop': 0,
'vue/singleline-html-element-content-newline': 0,
'vue/max-attributes-per-line': 0,
// Vue: Add extra rules
'vue/custom-event-name-casing': [0, 'camelCase'],
'camelcase': ['warn', { properties: 'never' }],
'vue/no-v-text': 1,
'vue/padding-line-between-blocks': 1,
'vue/require-direct-export': 1,
'vue/multi-word-component-names': 0,
// Allow @ts-ignore comment
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/no-unused-vars': 1,
'@typescript-eslint/no-empty-function': 1,
'@typescript-eslint/no-explicit-any': 0, // 改为警告
'no-unused-expressions': 'off',
'no-console': process.env.NODE_ENV === 'production' ? 2 : 1, // 生产环境禁用console
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/ban-types': 'off',
'import/no-unresolved': [2, { ignore: ['^@/'] }],
'import/extensions': [
2,
'error',
'ignorePackages',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
vue: 'off',
},
],
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'no-param-reassign': 0,
'prefer-regex-literals': 0,
'import/no-extraneous-dependencies': 0,
// 禁用 prefer-destructuring 规则,因为它对对象解构和数组解构都产生错误警告
'prefer-destructuring': 0,
'no-return-assign': ['error', 'except-parens'],
},
overrides: [
// 3. 为 .vue 文件提供更具体的解析器选项(如果需要)
{
files: ['*.vue'],
rules: {
// 在这里可以覆盖一些只针对 .vue 文件的规则
// 例如,vue-eslint-parser 已经处理了未使用的变量,所以可以关闭 TS 的检查
'@typescript-eslint/no-unused-vars': 'off',
},
},
// 4. 为 .tsx 文件单独配置(推荐)
{
files: ['*.tsx'],
parser: '@typescript-eslint/parser', // 直接使用 TS 解析器
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
project: path.resolve(__dirname, './tsconfig.json'),
},
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
},
// d.ts 文件配置保持不变
{
files: ['**/*.d.ts'],
parserOptions: { project: undefined },
rules: {
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/ban-types': 'off',
},
},
{
files: ['*.config.ts', '*.config.js'], // 匹配所有 .config.ts 和 .config.js 文件
parserOptions: {
project: undefined, // 关键:告诉 ESLint 这个文件不需要关联 TS 项目配置
},
rules: {
// 在这里可以关闭一些对配置文件不适用的规则
'import/no-named-as-default': 'off', // 例如,这个规则在配置文件中很常见
},
},
],
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: path.resolve(__dirname, './tsconfig.json'),
},
node: {
extensions: ['.js', '.ts', '.tsx', '.vue'],
},
},
},
ignorePatterns: ['.eslintrc.js', 'node_modules', 'dist', '*.config.js'],
};