[go: nahoru, domu]

blob: 5eb651538b618056cf33f3b53903f97ea80afd83 [file] [log] [blame]
Avi Drissman24976592022-09-12 15:24:311// Copyright 2017 The Chromium Authors
dpapadff82d512017-05-25 18:40:152// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5module.exports = {
6 'root': true,
7 'env': {
8 'browser': true,
dpapada06173092020-10-17 03:06:169 'es2020': true,
Christopher Lama5f2ad02018-12-05 10:05:5810 },
11 'parserOptions': {
dpapada06173092020-10-17 03:06:1612 'ecmaVersion': 2020,
dpapad12b3c472019-05-29 02:16:0513 'sourceType': 'module',
dpapadff82d512017-05-25 18:40:1514 },
15 'rules': {
16 // Enabled checks.
Dan Beam1a0d9dcb2019-01-08 09:05:3517 'brace-style': ['error', '1tbs'],
dpapadf4d855722022-07-19 01:28:1818
19 // https://google.github.io/styleguide/jsguide.html#features-arrays-trailing-comma
20 // https://google.github.io/styleguide/jsguide.html#features-objects-use-trailing-comma
21 'comma-dangle': ['error', 'always-multiline'],
22
Dan Beam1a0d9dcb2019-01-08 09:05:3523 'curly': ['error', 'multi-line', 'consistent'],
dpapadc21c6fb2022-04-01 07:12:1324 'new-parens': 'error',
dpapadb2b0d6c2022-06-27 19:45:1125 'no-array-constructor': 'error',
dpapadc7570be2022-03-28 08:28:2326 'no-console': ['error', {allow: ['info', 'warn', 'error', 'assert']}],
Dan Beamb1536652019-02-26 07:36:2527 'no-extra-boolean-cast': 'error',
dpapadff82d512017-05-25 18:40:1528 'no-extra-semi': 'error',
dpapad728cff02017-06-01 01:06:4229 'no-new-wrappers': 'error',
Christopher Lama5f2ad02018-12-05 10:05:5830 'no-restricted-properties': [
31 'error',
32 {
dpapad7b493a42019-06-22 02:07:0933 'property': '__lookupGetter__',
34 'message': 'Use Object.getOwnPropertyDescriptor',
35 },
36 {
37 'property': '__lookupSetter__',
38 'message': 'Use Object.getOwnPropertyDescriptor',
39 },
40 {
41 'property': '__defineGetter__',
42 'message': 'Use Object.defineProperty',
43 },
44 {
45 'property': '__defineSetter__',
46 'message': 'Use Object.defineProperty',
47 },
Dan Beam1aa00a122020-01-16 00:40:4148 {
49 'object': 'cr',
50 'property': 'exportPath',
51 'message': 'Use ES modules or cr.define() instead',
52 },
dpapad2674f9282017-05-31 19:40:3953 ],
dpapadbea253c32022-04-01 08:52:5754 'no-throw-literal': 'error',
dpapad2d023f92022-03-29 21:11:2355 'no-trailing-spaces': 'error',
Demetrios Papadopouloscf870bde2019-11-26 19:14:3456 'no-var': 'error',
57 'prefer-const': 'error',
dpapadab656922022-04-01 00:01:1158 'quotes': ['error', 'single', {allowTemplateLiterals: true}],
dpapad1e511b12017-05-31 03:31:2659 'semi': ['error', 'always'],
dpapad2674f9282017-05-31 19:40:3960
dpapadd631d172022-07-20 17:29:0161 // https://google.github.io/styleguide/jsguide.html#features-one-variable-per-declaration
62 'one-var': ['error', {
63 let: 'never',
64 const: 'never',
65 }],
66
dpapadff82d512017-05-25 18:40:1567 // TODO(dpapad): Add more checks according to our styleguide.
68 },
dpapadac97d7b62021-06-14 07:20:2669
70 'overrides': [{
71 'files': ['**/*.ts'],
72 'parser': './third_party/node/node_modules/@typescript-eslint/parser',
dpapadfa76653e2022-02-24 09:08:4073 'plugins': [
74 '@typescript-eslint',
75 ],
76 'rules': {
77 'no-unused-vars': 'off',
78 '@typescript-eslint/no-unused-vars': [
79 'error', {
80 argsIgnorePattern: '^_',
81 varsIgnorePattern: '^_',
82 }
dpapad5df23042022-03-21 19:22:3783 ],
84
85 'semi': 'off',
86 '@typescript-eslint/semi': ['error'],
dpapada2eca912022-03-28 09:36:4487
dpapad09279162022-07-07 18:34:0688 // https://google.github.io/styleguide/tsguide.html#arrayt-type
89 '@typescript-eslint/array-type': ['error', {
90 default: 'array-simple',
91 }],
92
dpapadd5332792022-07-11 21:15:1493 // https://google.github.io/styleguide/tsguide.html#type-assertions-syntax
94 '@typescript-eslint/consistent-type-assertions': ['error', {
95 assertionStyle: 'as',
96 }],
97
dpapadb1a935f2022-07-27 16:49:0698 // https://google.github.io/styleguide/tsguide.html#interfaces-vs-type-aliases
99 "@typescript-eslint/consistent-type-definitions": ['error', 'interface'],
100
dpapad684f427b2022-05-10 05:47:02101 // https://google.github.io/styleguide/jsguide.html#naming
dpapad50adcde2022-05-07 00:05:52102 '@typescript-eslint/naming-convention': [
103 'error',
104 {
dpapad684f427b2022-05-10 05:47:02105 selector: ['class', 'interface', 'typeAlias', 'enum', 'typeParameter'],
dpapad978c1dab2022-10-19 18:12:09106 format: ['StrictPascalCase'],
107 filter: {
108 regex: '^(' +
109 // Exclude TypeScript defined interfaces HTMLElementTagNameMap
110 // and HTMLElementEventMap.
111 'HTMLElementTagNameMap|HTMLElementEventMap|' +
112 // Exclude native DOM types which are always named like HTML<Foo>Element.
113 'HTML[A-Za-z]{0,}Element|' +
114 // Exclude native DOM interfaces.
115 'UIEvent|UIEventInit|DOMError|' +
116 // Exclude the deprecated WebUIListenerBehavior interface.
117 'WebUIListenerBehavior)$',
118 match: false,
119 },
dpapad50adcde2022-05-07 00:05:52120 },
121 {
dpapad50adcde2022-05-07 00:05:52122 selector: 'enumMember',
123 format: ['UPPER_CASE'],
124 },
dpapad684f427b2022-05-10 05:47:02125 {
126 selector: 'classMethod',
dpapade9ae77d2022-12-12 17:02:00127 format: ['strictCamelCase'],
dpapadb7286e82022-06-16 01:33:27128 modifiers: ['public'],
129 },
130 {
131 selector: 'classMethod',
dpapade9ae77d2022-12-12 17:02:00132 format: ['strictCamelCase'],
dpapadb7286e82022-06-16 01:33:27133 modifiers: ['private'],
dpapad684f427b2022-05-10 05:47:02134 trailingUnderscore: 'allow',
135 },
136 {
dpapade9d1fa72022-06-09 17:42:50137 selector: 'classProperty',
138 format: ['UPPER_CASE'],
dpapad588bb912022-06-15 05:35:33139 modifiers: ['private', 'static', 'readonly'],
140 },
141 {
142 selector: 'classProperty',
143 format: ['UPPER_CASE'],
144 modifiers: ['public', 'static', 'readonly'],
dpapade9d1fa72022-06-09 17:42:50145 },
146 {
147 selector: 'classProperty',
148 format: ['camelCase'],
dpapad588bb912022-06-15 05:35:33149 modifiers: ['public'],
150 },
151 {
152 selector: 'classProperty',
153 format: ['camelCase'],
154 modifiers: ['private'],
dpapade9d1fa72022-06-09 17:42:50155 trailingUnderscore: 'allow',
156 },
157 {
dpapad684f427b2022-05-10 05:47:02158 selector: 'parameter',
159 format: ['camelCase'],
160 leadingUnderscore: 'allow',
161 },
dpapadb17f3beb2022-05-10 21:34:13162 {
163 selector: 'function',
164 format: ['camelCase'],
165 },
dpapad50adcde2022-05-07 00:05:52166 ],
167
dpapada2eca912022-03-28 09:36:44168 '@typescript-eslint/member-delimiter-style': ['error', {
169 multiline: {
170 delimiter: 'comma',
171 requireLast: true,
172 },
173 singleline: {
174 delimiter: 'comma',
175 requireLast: false,
176 },
177 overrides: {
178 interface: {
179 multiline: {
180 delimiter: 'semi',
181 requireLast: true,
182 },
183 singleline: {
184 delimiter: 'semi',
185 requireLast: false,
186 },
187 },
188 },
dpapadb5aaf1a2022-07-11 18:00:41189 }],
190
191 // https://google.github.io/styleguide/tsguide.html#wrapper-types
192 '@typescript-eslint/ban-types': ['error', {
193 extendDefaults: false,
194 types: {
195 String: {
196 message: 'Use string instead',
197 fixWith: 'string',
198 },
199 Boolean: {
200 message: 'Use boolean instead',
201 fixWith: 'boolean',
202 },
203 Number: {
204 message: 'Use number instead',
205 fixWith: 'number',
206 },
207 Symbol: {
208 message: 'Use symbol instead',
209 fixWith: 'symbol',
210 },
211 BigInt: {
212 message: 'Use bigint instead',
213 fixWith: 'bigint',
214 },
215 }
216 }],
dpapadfa76653e2022-02-24 09:08:40217 }
dpapadac97d7b62021-06-14 07:20:26218 }]
dpapadff82d512017-05-25 18:40:15219};