71 lines
1.9 KiB
JavaScript
71 lines
1.9 KiB
JavaScript
|
module.exports = {
|
|||
|
root: true,
|
|||
|
env: {
|
|||
|
browser: true,
|
|||
|
es2021: true,
|
|||
|
node: true,
|
|||
|
},
|
|||
|
// 指定如何解析语法
|
|||
|
parser: 'vue-eslint-parser',
|
|||
|
// 优先级低于 parse 的语法解析配置
|
|||
|
parserOptions: {
|
|||
|
parser: '@typescript-eslint/parser',
|
|||
|
ecmaVersion: 'latest',
|
|||
|
sourceType: 'module',
|
|||
|
},
|
|||
|
// 继承某些已有的规则
|
|||
|
extends: [
|
|||
|
'plugin:vue/vue3-essential',
|
|||
|
'plugin:@typescript-eslint/recommended',
|
|||
|
'plugin:prettier/recommended', // 添加 prettier 插件
|
|||
|
],
|
|||
|
plugins: ['vue', '@typescript-eslint', 'import', 'prettier', 'simple-import-sort'],
|
|||
|
overrides: [
|
|||
|
{
|
|||
|
files: ['*.ts', '*.tsx'],
|
|||
|
parser: '@typescript-eslint/parser',
|
|||
|
},
|
|||
|
],
|
|||
|
rules: {
|
|||
|
'@typescript-eslint/ban-types': 'off',
|
|||
|
'@typescript-eslint/no-explicit-any': 'off',
|
|||
|
'@typescript-eslint/promise-function-async': 'off',
|
|||
|
'vue/multi-word-component-names': 'off',
|
|||
|
'simple-import-sort/imports': [
|
|||
|
'error',
|
|||
|
{
|
|||
|
groups: [
|
|||
|
[
|
|||
|
// 以字母(或数字或下划线)或“@”后面跟着字母开头的东西,通常为内置模块引入
|
|||
|
'^@?\\w',
|
|||
|
// 内部导入 "@/"
|
|||
|
'^@(/.*|$)',
|
|||
|
`^@/assets$`,
|
|||
|
`^@/components$`,
|
|||
|
`^@/config$`,
|
|||
|
`^@/hooks$`,
|
|||
|
`^@/plugins$`,
|
|||
|
`^@/router$`,
|
|||
|
`^@/store$`,
|
|||
|
`^@/styles$`,
|
|||
|
`^@/utils$`,
|
|||
|
// 父级导入. 把 `..` 放在最后.
|
|||
|
'^\\.\\.(?!/?$)',
|
|||
|
'^\\.\\./?$',
|
|||
|
// 同级导入. 把同一个文件夹.放在最后
|
|||
|
'^\\./(?=.*/)(?!/?$)',
|
|||
|
'^\\.(?!/?$)',
|
|||
|
'^\\./?$',
|
|||
|
// 样式导入.
|
|||
|
'^.+\\.?(css|less|scss)$',
|
|||
|
// 带有副作用导入,比如import 'a.css'这种.
|
|||
|
'^\\u0000',
|
|||
|
],
|
|||
|
],
|
|||
|
},
|
|||
|
],
|
|||
|
'simple-import-sort/exports': 'error', // 导出
|
|||
|
'import/order': 'off',
|
|||
|
},
|
|||
|
};
|