-
Notifications
You must be signed in to change notification settings - Fork 6
/
.eslintrc.cjs
66 lines (65 loc) · 2.01 KB
/
.eslintrc.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// ESLint 检查 .vue 文件需要单独配置编辑器:
// https://eslint.vuejs.org/user-guide/#editor-integrations
module.exports = {
root: true,
// https://github.com/vuejs/vue-eslint-parser#readme
// https://eslint.vuejs.org/user-guide/#usage
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
sourceType: 'module',
},
extends: [
// lint vue 文件
// eslint-config-taro配置包中没有引入依赖eslint-plugin-vue
// 所以需要项目安装eslint-plugin-vue
// 'taro/vue3',
'plugin:vue/vue3-recommended',
// eslint 集成prettier 规则,
// 需要先安装
// eslint-config-prettier
// eslint-plugin-prettier
// 1. disabled掉eslint中和prettier想冲突的规则
// 2. 实时以eslint 提示的方式显示prettier规则
// @see https://github.com/prettier/eslint-plugin-prettier
'plugin:prettier/recommended',
],
rules: {
'vue/multi-word-component-names': [
'error',
{
ignores: ['Home', 'Layout'],
},
],
},
// 方式一:
// lint js?(x) ts?(x)文件
// eslint-config-taro 没有引入相关依赖
// 需要项目单独安装:
// "eslint-plugin-import": "^2.26.0",
// "eslint-plugin-react": "^7.30.0",
// "eslint-plugin-react-hooks": "^4.5.0",
// glob functionally: https://github.com/isaacs/node-glob
//
// overrides: [{ files: ["**/*.js?(x)", "**/*.ts?(x)"], extends: ["taro"] }],
// 方式二:
// 不使用taro配置包,自定义lint ts文件
overrides: [
{
files: ['src/**/*.ts', 'slaves/**/*.ts'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
extraFileExtensions: ['.vue'],
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
excludedFiles: '*.test.ts',
},
],
};