|
| 1 | +module.exports = { |
| 2 | + root: true, |
| 3 | + env: { |
| 4 | + browser: true, |
| 5 | + node: true, |
| 6 | + es2021: true, |
| 7 | + }, |
| 8 | + parser: "vue-eslint-parser", |
| 9 | + extends: [ |
| 10 | + "eslint:recommended", |
| 11 | + "plugin:vue/vue3-recommended", |
| 12 | + "plugin:@typescript-eslint/recommended", |
| 13 | + "plugin:prettier/recommended", |
| 14 | + // eslint-config-prettier 的缩写 |
| 15 | + "prettier", |
| 16 | + ], |
| 17 | + parserOptions: { |
| 18 | + ecmaVersion: 12, |
| 19 | + parser: "@typescript-eslint/parser", |
| 20 | + sourceType: "module", |
| 21 | + ecmaFeatures: { |
| 22 | + jsx: true, |
| 23 | + }, |
| 24 | + }, |
| 25 | + // eslint-plugin-vue @typescript-eslint/eslint-plugin eslint-plugin-prettier的缩写 |
| 26 | + plugins: ["vue", "@typescript-eslint", "prettier"], |
| 27 | + rules: { |
| 28 | + "@typescript-eslint/ban-ts-ignore": "off", |
| 29 | + "@typescript-eslint/no-unused-vars": "off", |
| 30 | + "@typescript-eslint/explicit-function-return-type": "off", |
| 31 | + "@typescript-eslint/no-explicit-any": "off", |
| 32 | + "@typescript-eslint/no-var-requires": "off", |
| 33 | + "@typescript-eslint/no-empty-function": "off", |
| 34 | + "@typescript-eslint/no-use-before-define": "off", |
| 35 | + "@typescript-eslint/ban-ts-comment": "off", |
| 36 | + "@typescript-eslint/ban-types": "off", |
| 37 | + "@typescript-eslint/no-non-null-assertion": "off", |
| 38 | + "@typescript-eslint/explicit-module-boundary-types": "off", |
| 39 | + "vue/multi-word-component-names": 0, |
| 40 | + "no-var": "error", |
| 41 | + "prettier/prettier": "error", |
| 42 | + // 禁止出现console |
| 43 | + "no-console": "warn", |
| 44 | + // 禁用debugger |
| 45 | + "no-debugger": "warn", |
| 46 | + // 禁止出现重复的 case 标签 |
| 47 | + "no-duplicate-case": "warn", |
| 48 | + // 禁止出现空语句块 |
| 49 | + "no-empty": "warn", |
| 50 | + // 禁止不必要的括号 |
| 51 | + "no-extra-parens": "off", |
| 52 | + // 禁止对 function 声明重新赋值 |
| 53 | + "no-func-assign": "warn", |
| 54 | + // 禁止在 return、throw、continue 和 break 语句之后出现不可达代码 |
| 55 | + "no-unreachable": "warn", |
| 56 | + // 强制所有控制语句使用一致的括号风格 |
| 57 | + curly: "warn", |
| 58 | + // 要求 switch 语句中有 default 分支 |
| 59 | + "default-case": "warn", |
| 60 | + // 强制尽可能地使用点号 |
| 61 | + "dot-notation": "warn", |
| 62 | + // 要求使用 === 和 !== |
| 63 | + eqeqeq: "warn", |
| 64 | + // 禁止 if 语句中 return 语句之后有 else 块 |
| 65 | + "no-else-return": "warn", |
| 66 | + // 禁止出现空函数 |
| 67 | + "no-empty-function": "warn", |
| 68 | + // 禁用不必要的嵌套块 |
| 69 | + "no-lone-blocks": "warn", |
| 70 | + // 禁止使用多个空格 |
| 71 | + "no-multi-spaces": "warn", |
| 72 | + // 禁止多次声明同一变量 |
| 73 | + "no-redeclare": "warn", |
| 74 | + // 禁止在 return 语句中使用赋值语句 |
| 75 | + "no-return-assign": "warn", |
| 76 | + // 禁用不必要的 return await |
| 77 | + "no-return-await": "warn", |
| 78 | + // 禁止自我赋值 |
| 79 | + "no-self-assign": "warn", |
| 80 | + // 禁止自身比较 |
| 81 | + "no-self-compare": "warn", |
| 82 | + // 禁止不必要的 catch 子句 |
| 83 | + "no-useless-catch": "warn", |
| 84 | + // 禁止多余的 return 语句 |
| 85 | + "no-useless-return": "warn", |
| 86 | + // 禁止变量声明与外层作用域的变量同名 |
| 87 | + "no-shadow": "off", |
| 88 | + // 允许delete变量 |
| 89 | + "no-delete-var": "off", |
| 90 | + // 强制数组方括号中使用一致的空格 |
| 91 | + "array-bracket-spacing": "warn", |
| 92 | + // 强制在代码块中使用一致的大括号风格 |
| 93 | + "brace-style": "warn", |
| 94 | + // 强制使用骆驼拼写法命名约定 |
| 95 | + // camelcase: 'warn', |
| 96 | + // 强制使用一致的缩进 |
| 97 | + indent: "off", |
| 98 | + // 强制在 JSX 属性中一致地使用双引号或单引号 |
| 99 | + // 'jsx-quotes': 'warn', |
| 100 | + // 强制可嵌套的块的最大深度4 |
| 101 | + // 'max-depth': 'warn', |
| 102 | + // 强制最大行数 300 |
| 103 | + // "max-lines": ["warn", { "max": 1200 }], |
| 104 | + // 强制函数最大代码行数 50 |
| 105 | + // 'max-lines-per-function': ['warn', { max: 70 }], |
| 106 | + // 强制函数块最多允许的的语句数量20 |
| 107 | + "max-statements": ["warn", 100], |
| 108 | + // 强制回调函数最大嵌套深度 |
| 109 | + "max-nested-callbacks": ["warn", 3], |
| 110 | + // 强制函数定义中最多允许的参数数量 |
| 111 | + "max-params": ["warn", 3], |
| 112 | + // 强制每一行中所允许的最大语句数量 |
| 113 | + "max-statements-per-line": ["warn", { max: 1 }], |
| 114 | + // 要求方法链中每个调用都有一个换行符 |
| 115 | + "newline-per-chained-call": ["warn", { ignoreChainWithDepth: 3 }], |
| 116 | + // 禁止 if 作为唯一的语句出现在 else 语句中 |
| 117 | + "no-lonely-if": "warn", |
| 118 | + // 禁止空格和 tab 的混合缩进 |
| 119 | + "no-mixed-spaces-and-tabs": "warn", |
| 120 | + // 禁止出现多行空行 |
| 121 | + "no-multiple-empty-lines": "warn", |
| 122 | + // 强制使用分号; |
| 123 | + semi: ["warn", "always"], |
| 124 | + // 强制使用双引号 |
| 125 | + singleQuote: [0], |
| 126 | + // 强制在块之前使用一致的空格 |
| 127 | + "space-before-blocks": "warn", |
| 128 | + // 强制在 function的左括号之前使用一致的空格 |
| 129 | + // 'space-before-function-paren': ['warn', 'never'], |
| 130 | + // 强制在圆括号内使用一致的空格 |
| 131 | + "space-in-parens": "warn", |
| 132 | + // 要求操作符周围有空格 |
| 133 | + "space-infix-ops": "warn", |
| 134 | + // 强制在一元操作符前后使用一致的空格 |
| 135 | + "space-unary-ops": "warn", |
| 136 | + // 强制在注释中 // 或 /* 使用一致的空格 |
| 137 | + // "spaced-comment": "warn", |
| 138 | + // 强制在 switch 的冒号左右有空格 |
| 139 | + "switch-colon-spacing": "warn", |
| 140 | + // 强制箭头函数的箭头前后使用一致的空格 |
| 141 | + "arrow-spacing": "warn", |
| 142 | + "prefer-const": "warn", |
| 143 | + "prefer-rest-params": "warn", |
| 144 | + "no-useless-escape": "warn", |
| 145 | + "no-irregular-whitespace": "warn", |
| 146 | + "no-prototype-builtins": "warn", |
| 147 | + "no-fallthrough": "warn", |
| 148 | + "no-extra-boolean-cast": "warn", |
| 149 | + "no-case-declarations": "warn", |
| 150 | + "no-async-promise-executor": "warn", |
| 151 | + }, |
| 152 | + globals: { |
| 153 | + defineProps: "readonly", |
| 154 | + defineEmits: "readonly", |
| 155 | + defineExpose: "readonly", |
| 156 | + withDefaults: "readonly", |
| 157 | + }, |
| 158 | +}; |
0 commit comments