2023-05-24 11:08:08 +08:00
|
|
|
|
// 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,
|
|
|
|
|
'vue/setup-compiler-macros': true,
|
|
|
|
|
},
|
2023-10-17 10:35:21 +08:00
|
|
|
|
plugins: ['@typescript-eslint', 'simple-import-sort'],
|
2023-05-24 11:08:08 +08:00
|
|
|
|
extends: [
|
|
|
|
|
// Airbnb JavaScript Style Guide https://github.com/airbnb/javascript
|
|
|
|
|
'airbnb-base',
|
|
|
|
|
'plugin:@typescript-eslint/recommended',
|
|
|
|
|
'plugin:import/recommended',
|
|
|
|
|
'plugin:import/typescript',
|
|
|
|
|
'plugin:vue/vue3-recommended',
|
|
|
|
|
'plugin:prettier/recommended',
|
2023-10-10 20:06:38 +08:00
|
|
|
|
'./.eslintrc-auto-import.json',
|
2023-05-24 11:08:08 +08:00
|
|
|
|
],
|
|
|
|
|
settings: {
|
|
|
|
|
'import/resolver': {
|
|
|
|
|
typescript: {
|
|
|
|
|
project: path.resolve(__dirname, './tsconfig.json'),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
'prettier/prettier': 1,
|
|
|
|
|
// Vue: Recommended rules to be closed or modify
|
|
|
|
|
'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': [2, 'camelCase'],
|
|
|
|
|
'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,
|
2024-03-11 18:37:17 +08:00
|
|
|
|
'@typescript-eslint/no-duplicate-enum-values': 0,
|
2023-05-24 11:08:08 +08:00
|
|
|
|
'consistent-return': 'off',
|
2024-03-12 19:28:20 +08:00
|
|
|
|
'vue/return-in-computed-property': ['off'],
|
|
|
|
|
'vue/no-side-effects-in-computed-properties': 'off',
|
2023-05-24 11:08:08 +08:00
|
|
|
|
'import/extensions': [
|
|
|
|
|
2,
|
|
|
|
|
'ignorePackages',
|
|
|
|
|
{
|
|
|
|
|
js: 'never',
|
|
|
|
|
jsx: 'never',
|
|
|
|
|
ts: 'never',
|
|
|
|
|
tsx: 'never',
|
|
|
|
|
},
|
|
|
|
|
],
|
2024-03-03 13:45:26 +08:00
|
|
|
|
'no-debugger': 2,
|
2023-05-24 11:08:08 +08:00
|
|
|
|
'no-param-reassign': 0,
|
|
|
|
|
'prefer-regex-literals': 0,
|
|
|
|
|
'import/no-extraneous-dependencies': 0,
|
|
|
|
|
'import/no-cycle': 'off',
|
|
|
|
|
'import/order': 'off',
|
|
|
|
|
'class-methods-use-this': 'off',
|
|
|
|
|
'global-require': 0,
|
|
|
|
|
'no-plusplus': 'off',
|
|
|
|
|
'no-underscore-dangle': 'off',
|
2023-06-02 17:03:13 +08:00
|
|
|
|
'vue/attributes-order': 1,
|
2023-10-17 10:35:21 +08:00
|
|
|
|
'simple-import-sort/exports': 'error',
|
2024-01-20 15:30:12 +08:00
|
|
|
|
'no-case-declarations': 'off',
|
2023-10-17 10:35:21 +08:00
|
|
|
|
// 调整导入语句的顺序
|
|
|
|
|
'simple-import-sort/imports': [
|
|
|
|
|
'error',
|
|
|
|
|
{
|
|
|
|
|
groups: [
|
|
|
|
|
[
|
|
|
|
|
'^vue$',
|
|
|
|
|
'^vue-router$',
|
|
|
|
|
'^vue-i18n$',
|
|
|
|
|
'^pinia$',
|
|
|
|
|
'^@vueuse/core$',
|
|
|
|
|
'^@arco-design/web-vue$',
|
|
|
|
|
'^monaco-editor$',
|
|
|
|
|
'^lodash-es$',
|
|
|
|
|
'^axios$',
|
|
|
|
|
'^dayjs$',
|
|
|
|
|
'^jsencrypt$',
|
|
|
|
|
'^echarts$',
|
|
|
|
|
'^color$',
|
2023-11-01 15:23:15 +08:00
|
|
|
|
'^localforage$',
|
2024-01-17 11:51:30 +08:00
|
|
|
|
'vue-draggable-plus',
|
2024-01-20 15:30:12 +08:00
|
|
|
|
'jsonpath-plus',
|
2023-10-17 10:35:21 +08:00
|
|
|
|
], // node依赖
|
|
|
|
|
['.*/assets/.*', '^@/assets$'], // 项目静态资源
|
|
|
|
|
['^@/components/pure/.*', '^@/components/business/.*', '.*\\.vue$'], // 组件
|
|
|
|
|
[
|
|
|
|
|
'^@/api($|/.*)',
|
|
|
|
|
'^@/config($|/.*)',
|
|
|
|
|
'^@/directive($|/.*)',
|
|
|
|
|
'^@/hooks($|/.*)',
|
|
|
|
|
'^@/locale($|/.*)',
|
|
|
|
|
'^@/router($|/.*)',
|
|
|
|
|
'^@/store($|/.*)',
|
|
|
|
|
'^@/utils($|/.*)',
|
|
|
|
|
], // 项目公共模块
|
|
|
|
|
['^@/models($|/.*)', '^@/enums($|/.*)'], // model、enum
|
|
|
|
|
['^type'], // 第三方类型声明 or 全局类型声明
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
2023-05-24 11:08:08 +08:00
|
|
|
|
},
|
|
|
|
|
// 对特定文件进行配置
|
|
|
|
|
overrides: [
|
|
|
|
|
{
|
|
|
|
|
files: ['src/enums/**/*.ts'],
|
|
|
|
|
rules: {
|
|
|
|
|
'no-shadow': 'off', // eslint会报错提示重复声明,暂未找到问题原因,先关闭
|
|
|
|
|
// 可以在这里添加更多的规则禁用
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|