forked from Tencent/Hippy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
197 lines (188 loc) · 4.73 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'eslint-config-tencent',
'plugin:react/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
],
plugins: [
'@typescript-eslint',
'jsx-a11y',
],
env: {
browser: true,
node: true,
es6: true,
},
parserOptions: {
ecmaFeatures: {
jsx: true,
legacyDecorators: true,
experimentalObjectRestSpread: true,
},
ecmaVersion: 2018,
sourceType: 'module',
},
globals: {
__PLATFORM__: true,
__GLOBAL__: true,
Hippy: true,
},
rules: {
indent: 2,
'no-multi-spaces': 2,
'no-restricted-syntax': [
'warn',
{
selector: 'ForInStatement',
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
},
{
selector: 'LabeledStatement',
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],
'no-mixed-operators': ['error', {
groups: [
['%', '**'],
['%', '+'],
['%', '-'],
['%', '*'],
['%', '/'],
['&', '|', '<<', '>>', '>>>'],
['==', '!=', '===', '!=='],
['&&', '||'],
],
allowSamePrecedence: false,
}],
'func-call-spacing': 'off',
'new-cap': [
'error',
{
newIsCap: true,
newIsCapExceptions: [],
capIsNew: false,
capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'],
properties: false,
},
],
'prefer-destructuring': [
'warn',
{
VariableDeclarator: {
array: false,
object: true,
},
AssignmentExpression: {
array: true,
object: false,
},
},
{
enforceForRenamedProperties: false,
},
],
quotes: [
'error',
'single',
{
allowTemplateLiterals: false,
},
],
'react/no-deprecated': 0,
// Ignore the dependency by each package
'import/no-unresolved': 'off',
// Allow import name different with file name
'import/no-named-as-default': 'off',
// Allow imoprt cycle
'import/no-cycle': 'off',
// Disable prop-types
'react/prop-types': 'off',
// Turn of extensions checking temporary
'import/extensions': 'off',
// https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules/namespace.md#allowcomputed
'import/namespace': [
'error',
{
allowComputed: true,
},
],
// Allow import from devDependencies
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'scripts/*.js',
// FIXME: seems not working
'packages/**/types/*.d.ts',
'packages/**/__tests__/*.test.js',
'examples/**/scripts/*.js',
],
},
],
// Allow tsx as the jsx file
'react/jsx-filename-extension': [
'error',
{
extensions: ['.tsx', '.jsx'],
},
],
// Allow global underscore in dangle
'no-underscore-dangle': [
'error',
{
allow: [
'__ISHIPPY__',
'__GLOBAL__',
'__HIPPYNATIVEGLOBAL__',
'__instanceId__',
'_reactInternalFiber',
],
},
],
},
settings: {
'import/resolver': {
alias: {
map: [
['he', './packages/hippy-vue/util/entity-decoder'],
['@localTypes', './packages/types'],
['@vue', './packages/hippy-vue/src'],
['@router', './packages/hippy-vue-router/src'],
['@css-loader', './packages/hippy-vue-css-loader/src'],
['@native-components', './packages/hippy-vue-native-components/src'],
],
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
},
},
},
overrides: [
{
files: ['**/*.ts', '**/*.tsx'],
rules: {
// Allow interface export
'no-undef': 'off',
// Disable props checking
'react/prop-types': 'off',
// Force use 2 space for indent
'@typescript-eslint/indent': ['error', 2],
// Note you must disable the base rule as it can report incorrect errors
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: false,
},
],
},
},
],
};