-
Notifications
You must be signed in to change notification settings - Fork 1
/
syntax.js
322 lines (284 loc) · 8.88 KB
/
syntax.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
"use strict";
/**
* Rules that disallow outdated or confusing syntax
*/
module.exports = {
rules: {
/**
* Disallows the comma operator to be used.
*
* @see https://palantir.github.io/tslint/rules/ban-comma-operator/
*/
"ban-comma-operator": true,
/**
* Prefer an interface declaration over a type literal (`type T = { ... }`)
*
* @see https://palantir.github.io/tslint/rules/interface-over-type-literal/
*/
"interface-over-type-literal": true,
/**
* Doesn't allow `void` to be used in union types.
*
* @see https://palantir.github.io/tslint/rules/invalid-void/
*
* This rule is disabled because it is useful to define types that can be assigned a function
* that returns a value or a function that returns nothing (void).
*/
"invalid-void": false,
/**
* Only allows labels in sensible locations.
*
* @see https://palantir.github.io/tslint/rules/label-position/
*/
"label-position": true,
/**
* Requires parentheses when invoking a constructor via the `new` keyword.
*
* @see https://palantir.github.io/tslint/rules/new-parens/
*/
"new-parens": true,
/**
* Requires the use of `as Type` for type assertions instead of `<Type>`.
*
* @see https://palantir.github.io/tslint/rules/no-angle-bracket-type-assertion/
*/
"no-angle-bracket-type-assertion": true,
/**
* Disallows usages of `any` as a type declaration.
*
* @see https://palantir.github.io/tslint/rules/no-any/
*/
"no-any": {
severity: "warning"
},
/**
* Disallows use of `arguments.callee`.
*
* @see https://palantir.github.io/tslint/rules/no-arg/
*/
"no-arg": true,
/**
* Warns on comparison to a boolean literal, as in `x === true`.
*
* @see https://palantir.github.io/tslint/rules/no-boolean-literal-compare/
*/
"no-boolean-literal-compare": true,
/**
* Bans the use of specified `console` methods.
*
* @see https://palantir.github.io/tslint/rules/no-console/
*/
"no-console": {
// Console methods should only be used for CLIs,
// and ONLY in the actual CLI code, NOT the accompanying library
severity: "default",
},
/**
* Disallows internal `module`
*
* @see https://palantir.github.io/tslint/rules/no-internal-module/
*/
"no-internal-module": true,
/**
* Disallows use of internal `module`s and `namespace`s.
*
* @see https://palantir.github.io/tslint/rules/no-namespace/
*/
"no-namespace": {
severity: "default",
options: ["allow-declarations"],
},
/**
* Disallows parameter properties in class constructors.
*
* @see https://palantir.github.io/tslint/rules/no-parameter-properties/
*/
"no-parameter-properties": true,
/**
* Disallows `/// <reference path=>` imports (use ES6-style imports instead).
*
* @see https://palantir.github.io/tslint/rules/no-reference/
*/
"no-reference": true,
/**
* Don't `<reference types="foo" />` if you import `foo` anyway.
*
* @see https://palantir.github.io/tslint/rules/no-reference-import/
*/
"no-reference-import": true,
/**
* Disallows invocation of `require()`.
*
* @see https://palantir.github.io/tslint/rules/no-require-imports/
*/
"no-require-imports": true,
/**
* Disallows unnecessary `return await`.
*
* @see https://palantir.github.io/tslint/rules/no-return-await/
*/
"no-return-await": 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`).
*
* @see https://palantir.github.io/tslint/rules/no-string-literal/
*/
"no-string-literal": true,
/**
* Disallows unnecessary references to `this`.
*
* @see https://palantir.github.io/tslint/rules/no-this-assignment/
*/
"no-this-assignment": {
severity: "default",
options: [{
"allow-destructuring": true,
}]
},
/**
* Replaces `x => f(x)` with just `f`.
* To catch more cases, enable `only-arrow-functions` and `arrow-return-shorthand` too.
*
* @see https://palantir.github.io/tslint/rules/no-unnecessary-callback-wrapper/
*
* This rule is currently disabled because it incorrectly compares function signatures,
* which can result in runtime errors
* @see https://github.com/palantir/tslint/issues/2430
*/
"no-unnecessary-callback-wrapper": false,
/**
* Disallows classes that are not strictly necessary.
*
* @see https://palantir.github.io/tslint/rules/no-unnecessary-class/
*/
"no-unnecessary-class": {
severity: "default",
options: [
"allow-empty-class"
]
},
/**
* Forbids a `var`/`let` statement or destructuring initializer to be initialized to `undefined`.
*
* @see https://palantir.github.io/tslint/rules/no-unnecessary-initializer/
*/
"no-unnecessary-initializer": {
severity: "warning"
},
/**
* Warns when a namespace qualifier (`A.x`) is unnecessary.
*
* @see https://palantir.github.io/tslint/rules/no-unnecessary-qualifier/
*/
"no-unnecessary-qualifier": {
severity: "warning"
},
/**
* Warns if a type assertion does not change the type of an expression.
*
* @see https://palantir.github.io/tslint/rules/no-unnecessary-type-assertion/
*/
"no-unnecessary-type-assertion": {
severity: "warning"
},
/**
* Disallows unused expression statements.
*
* @see https://palantir.github.io/tslint/rules/no-unused-expression/
*/
"no-unused-expression": {
severity: "default",
options: [
"allow-fast-null-checks"
]
},
/**
* Disallows usage of the `var` keyword.
*
* @see https://palantir.github.io/tslint/rules/no-var-keyword/
*/
"no-var-keyword": true,
/**
* Disallows the use of require statements except in import statements.
*
* @see https://palantir.github.io/tslint/rules/no-var-requires/
*/
"no-var-requires": true,
/**
* Disallows traditional (non-arrow) function expressions.
*
* @see https://palantir.github.io/tslint/rules/only-arrow-functions/
*/
"only-arrow-functions": {
severity: "default",
options: [
"allow-declarations",
"allow-named-functions"
]
},
/**
* Recommends a `for-of` loop over a standard `for` loop if the index is only used to access the array being iterated.
*
* @see https://palantir.github.io/tslint/rules/prefer-for-of/
*/
"prefer-for-of": true,
/**
* Prefer `foo(): void` over `foo: () => void` in interfaces and types.
*
* @see https://palantir.github.io/tslint/rules/prefer-method-signature/
*/
"prefer-method-signature": true,
/**
* Enforces the use of the ES2018 object spread operator over `Object.assign()` where appropriate.
*
* @see https://palantir.github.io/tslint/rules/prefer-object-spread/
*
* This rule is currently disabled because the object spread operator is not supported in Node 6.
* TODO: Enable this rule once Node 6 goes out of LTS (April 2019)
*/
"prefer-object-spread": false,
/**
* Prefer a `switch` statement to an `if` statement with simple `===` comparisons.
*
* @see https://palantir.github.io/tslint/rules/prefer-switch/
*/
"prefer-switch": true,
/**
* Prefer a template expression over string literal concatenation.
*
* @see https://palantir.github.io/tslint/rules/prefer-template/
*
* This rule is disabled because it's often more clear to explicitly concatenate string literals.
* Multi-line string templates are also not ideal in some places.
*/
"prefer-template": false,
/**
* Prefer `while` loops instead of `for` loops without an initializer and incrementor.
*
* @see https://palantir.github.io/tslint/rules/prefer-while/
*/
"prefer-while": true,
/**
* Ban the use of `this` in static methods
*
* @see https://palantir.github.io/tslint/rules/static-this/
*/
"static-this": true,
/**
* Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter.
*
* @see https://palantir.github.io/tslint/rules/unified-signatures/
*
* This rule is disabled because it's often more clear to have separate overload signatures.
*/
"unified-signatures": false,
/**
* Prevents unnecessary and/or misleading scope bindings on functions.
*
* @see https://palantir.github.io/tslint/rules/unnecessary-bind/
*/
"unnecessary-bind": true,
}
};