forked from Tencent/Hippy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
149 lines (137 loc) · 3.7 KB
/
.eslintrc.js
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
const path = require('path');
function resolveVue(p) {
return path.resolve(__dirname, './node_modules/vue/src/', p);
}
function resolvePackage(src, extra = 'src') {
return path.resolve(__dirname, './packages/', src, extra);
}
module.exports = {
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaFeatures: {
jsx: true,
legacyDecorators: true,
experimentalObjectRestSpread: true,
},
ecmaVersion: 2018,
sourceType: 'module',
},
extends: [
'eslint-config-tencent',
'plugin:react/recommended',
'plugin:vue/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
],
plugins: [
'vue',
'@typescript-eslint',
'jsx-a11y',
],
overrides: [
{
files: ['**/*.ts', '**/*.tsx'],
extends: ['eslint-config-tencent/ts'],
rules: {
// Allow interface export
'no-undef': 'off',
// Note you must disable the base rule as it can report incorrect errors
'no-unused-vars': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/prefer-for-of': 'off',
},
},
],
env: {
browser: true,
node: true,
es6: true,
},
globals: {
__PLATFORM__: 'writable',
__GLOBAL__: 'writable',
Hippy: 'writable',
WebSocket: 'writable',
requestIdleCallback: 'writable',
cancelIdleCallback: 'writable',
},
rules: {
'no-restricted-globals': 'off',
semi: ['error', 'always'],
// Allow more than one component per file
'vue/one-component-per-file': 'off',
// Allow no default value
'vue/require-default-prop': 'off',
// Allow no prop type
'vue/require-prop-types': 'off',
// Allow event name not kebab-case
'vue/custom-event-name-casing': 'off',
'import/no-unresolved': 'off',
// Allow import name different with file name
'import/no-named-as-default': 'off',
// Allow import cycle
'import/no-cycle': 'off',
// Disable prop-types
'react/prop-types': 'off',
// Disable deprecated
'react/no-deprecated': 'off',
'import/namespace': [
'error',
{
allowComputed: true,
},
],
// Allow tsx as the jsx file
'react/jsx-filename-extension': [
'error',
{
extensions: ['.tsx', '.jsx'],
},
],
// Auto range order of imported module
'import/order': ['error'],
// Allow global underscore in dangle
'no-underscore-dangle': [
'warn',
{
allow: [
'__PLATFORM__',
'__HIPPYCURDIR__',
'__ISHIPPY__',
'__GLOBAL__',
'__HIPPYNATIVEGLOBAL__',
'__instanceId__',
'_reactInternalFiber',
'_reactInternals',
],
},
],
},
settings: {
react: {
version: 'detect', // React version. "detect" automatically picks the version you have installed.
},
'import/ignore': [resolveVue('/')],
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx', 'd.ts'],
},
alias: {
map: [
['@vue', resolvePackage('hippy-vue')],
['@router', resolvePackage('hippy-vue-router')],
['@css-loader', resolvePackage('hippy-vue-css-loader')],
['@native-components', resolvePackage('hippy-vue-native-components')],
['vue', resolveVue('core/index')],
['web', resolveVue('platforms/web')],
['core', resolveVue('core')],
['shared', resolveVue('shared')],
['sfc', resolveVue('sfc')],
['he', path.resolve(__dirname, './packages/hippy-vue/src/util/entity-decoder')],
],
},
},
},
};