forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eslintrc.js
239 lines (225 loc) · 6.92 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module.exports = {
'root': true,
'env': {
'browser': true,
'es2020': true,
},
'parserOptions': {
'ecmaVersion': 2020,
'sourceType': 'module',
},
'rules': {
// Enabled checks.
'brace-style': ['error', '1tbs'],
// https://google.github.io/styleguide/jsguide.html#features-arrays-trailing-comma
// https://google.github.io/styleguide/jsguide.html#features-objects-use-trailing-comma
'comma-dangle': ['error', 'always-multiline'],
'curly': ['error', 'multi-line', 'consistent'],
'new-parens': 'error',
'no-array-constructor': 'error',
'no-console': ['error', {allow: ['info', 'warn', 'error', 'assert']}],
'no-extra-boolean-cast': 'error',
'no-extra-semi': 'error',
'no-new-wrappers': 'error',
'no-restricted-imports': ['error', {
'paths': [{
'name': 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js',
'importNames': ['Polymer'],
'message': 'Use PolymerElement instead.',
},
{
'name': '//resources/polymer/v3_0/polymer/polymer_bundled.min.js',
'importNames': ['Polymer'],
'message': 'Use PolymerElement instead.',
}],
}],
'no-restricted-properties': [
'error',
{
'property': '__lookupGetter__',
'message': 'Use Object.getOwnPropertyDescriptor',
},
{
'property': '__lookupSetter__',
'message': 'Use Object.getOwnPropertyDescriptor',
},
{
'property': '__defineGetter__',
'message': 'Use Object.defineProperty',
},
{
'property': '__defineSetter__',
'message': 'Use Object.defineProperty',
},
{
'object': 'cr',
'property': 'exportPath',
'message': 'Use ES modules or cr.define() instead',
},
],
'no-throw-literal': 'error',
'no-trailing-spaces': 'error',
'no-var': 'error',
'prefer-const': 'error',
'quotes': ['error', 'single', {allowTemplateLiterals: true}],
'semi': ['error', 'always'],
// https://google.github.io/styleguide/jsguide.html#features-one-variable-per-declaration
'one-var': ['error', {
let: 'never',
const: 'never',
}],
// TODO(dpapad): Add more checks according to our styleguide.
},
'overrides': [{
'files': ['**/*.ts'],
'parser': './third_party/node/node_modules/@typescript-eslint/parser',
'plugins': [
'@typescript-eslint',
],
'rules': {
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error', {
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
}
],
'semi': 'off',
'@typescript-eslint/semi': ['error'],
// https://google.github.io/styleguide/tsguide.html#arrayt-type
'@typescript-eslint/array-type': ['error', {
default: 'array-simple',
}],
// https://google.github.io/styleguide/tsguide.html#type-assertions-syntax
'@typescript-eslint/consistent-type-assertions': ['error', {
assertionStyle: 'as',
}],
// https://google.github.io/styleguide/tsguide.html#interfaces-vs-type-aliases
"@typescript-eslint/consistent-type-definitions": ['error', 'interface'],
// https://google.github.io/styleguide/jsguide.html#naming
'@typescript-eslint/naming-convention': [
'error',
{
selector: ['class', 'interface', 'typeAlias', 'enum', 'typeParameter'],
format: ['StrictPascalCase'],
filter: {
regex: '^(' +
// Exclude TypeScript defined interfaces HTMLElementTagNameMap
// and HTMLElementEventMap.
'HTMLElementTagNameMap|HTMLElementEventMap|' +
// Exclude native DOM types which are always named like HTML<Foo>Element.
'HTML[A-Za-z]{0,}Element|' +
// Exclude native DOM interfaces.
'UIEvent|UIEventInit|DOMError|' +
// Exclude the deprecated WebUIListenerBehavior interface.
'WebUIListenerBehavior)$',
match: false,
},
},
{
selector: 'enumMember',
format: ['UPPER_CASE'],
},
{
selector: 'classMethod',
format: ['strictCamelCase'],
modifiers: ['public'],
},
{
selector: 'classMethod',
format: ['strictCamelCase'],
modifiers: ['private'],
trailingUnderscore: 'allow',
// Disallow the 'Tap_' suffix, in favor of 'Click_' in event handlers.
// Note: Unfortunately this ESLint rule does not provide a way to
// customize the error message to better inform developers.
custom: {
regex: '^on[a-zA-Z0-9]+Tap$',
match: false,
},
},
{
selector: 'classProperty',
format: ['UPPER_CASE'],
modifiers: ['private', 'static', 'readonly'],
},
{
selector: 'classProperty',
format: ['UPPER_CASE'],
modifiers: ['public', 'static', 'readonly'],
},
{
selector: 'classProperty',
format: ['camelCase'],
modifiers: ['public'],
},
{
selector: 'classProperty',
format: ['camelCase'],
modifiers: ['private'],
trailingUnderscore: 'allow',
},
{
selector: 'parameter',
format: ['camelCase'],
leadingUnderscore: 'allow',
},
{
selector: 'function',
format: ['camelCase'],
},
],
'@typescript-eslint/member-delimiter-style': ['error', {
multiline: {
delimiter: 'comma',
requireLast: true,
},
singleline: {
delimiter: 'comma',
requireLast: false,
},
overrides: {
interface: {
multiline: {
delimiter: 'semi',
requireLast: true,
},
singleline: {
delimiter: 'semi',
requireLast: false,
},
},
},
}],
// https://google.github.io/styleguide/tsguide.html#wrapper-types
'@typescript-eslint/ban-types': ['error', {
extendDefaults: false,
types: {
String: {
message: 'Use string instead',
fixWith: 'string',
},
Boolean: {
message: 'Use boolean instead',
fixWith: 'boolean',
},
Number: {
message: 'Use number instead',
fixWith: 'number',
},
Symbol: {
message: 'Use symbol instead',
fixWith: 'symbol',
},
BigInt: {
message: 'Use bigint instead',
fixWith: 'bigint',
},
}
}],
}
}]
};