-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
tslint.js
353 lines (353 loc) · 10.3 KB
/
tslint.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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
module.exports = {
linterOptions: {
exclude: ["node_modules", "dist", "coverage", "dev"],
},
rules: {
/**
* Enforces function overloads to be consecutive
*/
"adjacent-overload-signatures": true,
/**
* Bans specific types from bening used. Does not
* ban the corresponding runtime objects from being
* used.
*/
"ban-types": [
true,
[
["Object", "Avoid using the `Object` type. Did you mean `object`?"],
[
"Function",
"Avoid using the `Function` type. Prefer a specific function type, like `() => void`.",
],
["Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?"],
["Number", "Avoid using the `Number` type. Did you mean `number`?"],
["String", "Avoid using the `String` type. Did you mean `string`?"],
["Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?"],
],
],
/**
* Disallows internal `module`
*/
"no-internal-module": true,
/**
* Disallows reassigning function parameters
*/
"no-parameter-reassignment": true,
/**
* Disallows `/// <reference path=>` imports
* (use ES6-style imports instead)
*/
"no-reference": true,
/**
* Warns if a type assertion does not change
* the type of an expression
*/
"no-unnecessary-type-assertion": true,
"prefer-for-of": false,
/**
* Requires any function or method that returns a promise
* to be marked async.
*/
"promise-function-async": true,
/**
* Warns for any two overloads that could be unified into
* one by using a union or an optional/rest parameter.
*/
"unified-signatures": true,
/**
* Warns for an awaited value that is not a Promise.
*/
"await-promise": true,
/**
* Disallows the comma operator to be used.
*/
"ban-comma-operator": true,
/**
* Disallows bitwise operators.
*/
"no-bitwise": true,
/**
* Disallows any type of assignment in conditionals.
*/
"no-conditional-assignment": true,
/**
* Bans the use of console.log and console.dir.
* It's fine to use these while debugging, but they
* should not be committed.
*/
"no-console": [true, "log", "dir"],
/**
* Disallows access to the constructors of `String`,
* `Number`, and `Boolean`.
*
* Disallows constructor use such as `new Number(foo)`
* but does not disallow `Number(foo)`.
*/
"no-construct": true,
/**
* Disallows `debugger;` statements.
*
* These are fine to use in development, but should not
* be committed.
*/
"no-debugger": true,
/**
* Warns if `super()` appears twice in a constructor.
*/
"no-duplicate-super": true,
/**
* Prevents duplicate cases in switch statements.
*/
"no-duplicate-switch-case": true,
/**
* Disallows duplicate variable declarations in
* the same block scope.
*/
"no-duplicate-variable": true,
/**
* Disallows empty blocks.
*
* Blocks with a comment inside are not considered empty.
*/
"no-empty": true,
/**
* Disallows `eval` function invocations.
*/
"no-eval": true,
/**
* Promises returned by functions must be handled
* appropriately.
*
* Unhandled Promises can cause unexpected behavior,
* such as resolving at unexpected times.
*/
"no-floating-promises": true,
/**
* Disallows iterating over an array with a for-in loop.
*/
"no-for-in-array": true,
/**
* Disallows importing modules that are not listed as
* dependency in the project’s package.json
*
* Disallows importing transient dependencies and modules
* installed above your package’s root directory.
*/
"no-implicit-dependencies": [true, "dev", "optional"],
/**
* Warns on use of `${` in non-template strings.
*/
"no-invalid-template-strings": true,
/**
* Disallows using the `this` keyword outside of classes.
*/
"no-invalid-this": true,
/**
* Warns on apparent attempts to define constructors for
* interfaces or new for classes.
*/
"no-misused-new": true,
/**
* Forbids an object literal to appear in a type assertion
* expression. Casting to `any` is still allowed.
*
* Disabled because it prevents using the new `as const` syntax
*/
"no-object-literal-type-assertion": false,
/**
* Disallows shadowing variable declarations.
*/
"no-shadowed-variable": true,
/**
* Forbids array literals to contain missing elements.
*/
"no-sparse-arrays": true,
/**
* Forbids unnecessary string literal property access.
* Allows `obj["prop-erty"]` (can’t be a regular property
* access). Disallows `obj["property"]` (should be
* `obj.property`).
*/
"no-string-literal": true,
/**
* Disallows falling through case statements.
*/
"no-switch-case-fall-through": true,
/**
* Disallows unnecessary references to `this`.
*
* Use arrow functions instead.
*/
"no-this-assignment": true,
/**
* Warns when a method is used outside of a
* method call.
*
* Use arrow function properties instead.
*/
"no-unbound-method": [true, "ignore-static"],
/**
* Disallows classes that are not strictly necessary.
*/
"no-unnecessary-class": true,
/**
* Disallows control flow statements, such as `return`,
* `continue`, `break` and `throw` in finally blocks.
*/
"no-unsafe-finally": true,
/**
* Disallows unused expression statements.
*
* Unused expressions are expression statements which are
* not assignments or function calls (and thus usually no-ops).
*
* We allow `e && e.preventDefault();` as a short hand for
* `if (e) e.preventDefault();`
*/
"no-unused-expression": [true, "allow-fast-null-checks"],
/**
* Disallows usage of the `var` keyword.
*
* Use `let` or `const` instead.
*/
"no-var-keyword": true,
/**
* Requires expressions of type void to
* appear in statement position.
*/
"no-void-expression": [true, "ignore-arrow-function-shorthand"],
/**
* Requires the radix parameter to be
* specified when calling `parseInt`.
*/
radix: true,
/**
* When adding two variables, operands must both
* be of type number or of type string.
*/
"restrict-plus-operands": true,
/**
* Warns for type predicates that are always true
* or always false. Works for ‘typeof’ comparisons
* to constants (e.g. ‘typeof foo === “string”’),
* and equality comparison to ‘null’/’undefined’.
* (TypeScript won’t let you compare ‘1 === 2’,
* but it has an exception for ‘1 === undefined’.)
* Does not yet work for ‘instanceof’. Does not
* warn for ‘if (x.y)’ where ‘x.y’ is always truthy.
* For that, see strict-boolean-expressions.
*
* This rule requires strictNullChecks to work properly.
*/
"strict-type-predicates": true,
/**
* Requires `===` and `!==` in place of `==` and `!=`
*
* Also allows `== null` and `!= null` as a shorthand
* for `x === null || x === undefined` and `x !== null || x !== undefined`
*/
"triple-equals": [true, "allow-null-check"],
/**
* Enforces use of the isNaN() function to check for
* NaN references instead of a comparison to the NaN
* constant.
*/
"use-isnan": true,
/**
* Warns when deprecated APIs are used.
*
* Any usage of an identifier with the `[at]deprecated` JSDoc
* annotation will trigger a warning. See:
* http://usejsdoc.org/tags-deprecated.html
*/
deprecation: true,
/**
* Disallows multiple import statements from the same module.
*/
"no-duplicate-imports": true,
/**
* Disallows mergeable namespaces in the same file.
*/
"no-mergeable-namespace": true,
/**
* Requires that variable declarations use `const` instead of
* `let` and `var` if possible.
*
* If a variable is only assigned to once when it is declared,
* it should be declared using `const`
*/
"prefer-const": true,
/**
* Requires that private variables are marked as `readonly`
* if they’re never modified outside of the constructor.
*
* If a private variable is only assigned to in the constructor,
* it should be declared as `readonly`.
*/
"prefer-readonly": true,
/**
* An interface or literal type with just a call signature can
* be written as a function type.
*/
"callable-types": true,
/**
* Enforces PascalCased class and interface names.
*/
"class-name": true,
/**
* Enforces UTF-8 file encoding.
*/
encoding: true,
/**
* Enforces basic whitespace formatting rules for
* JSDoc comments.
*/
"jsdoc-format": true,
/**
* Requires the use of `as Type` for type assertions instead of `<Type>`.
*/
"no-angle-bracket-type-assertion": true,
/**
* Disallows parameter properties in class constructors.
*/
"no-parameter-properties": true,
/**
* Forbids JSDoc which duplicates TypeScript functionality.
*/
"no-redundant-jsdoc": true,
/**
* Don’t <reference types="foo" /> if you import foo anyway.
*/
"no-reference-import": true,
/**
* Forbids a ‘var’/’let’ statement or destructuring initializer
* to be initialized to ‘undefined’.
*/
"no-unnecessary-initializer": true,
/**
* Disallows multiple variable definitions in the same declaration statement.
*/
"one-variable-per-declaration": true,
/**
* Prefer while loops instead of for loops
* without an initializer and incrementor.
*/
"prefer-while": true,
/**
* Prefer `return;` in void functions and
* `return undefined;` in value-returning
* functions.
*/
"return-undefined": true,
/**
* Checks whether the final clause of a
* `switch` statement ends in `break;`.
*/
"switch-final-break": [true, "always"],
/**
* Disallows variable names like `any`, `Number`, `string` etc.
*/
"variable-name": [true, "ban-keywords"],
},
};