This repository has been archived by the owner on Sep 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tslint.json
210 lines (167 loc) · 6.14 KB
/
tslint.json
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
{
"rulesDirectory": ["tslint-no-unused-expression-chai"],
// https://palantir.github.io/tslint/rules/
"rules": {
// TypeScript Specific
// If the compiler is sure of the type of something, don't bother declaring
// the type of it.
"no-inferrable-types": true,
// /// <reference path= is long dead; use ES6 imports for type definitions.
"no-reference": true,
// Use `for (value of thing)` over index based iteration. This isn't C.
"prefer-for-of": true,
// Any function that returns a `Promise` should be marked `async`. This is
// helpful for readability, and also ensures that the function never throws
// an exception (and instead guarantees a rejection for all errors).
//
// TODO: https://github.com/palantir/tslint/issues/1603
// "promise-function-async": true,
// We're crazy and like compressed whitespace for type declarations. It
// visually groups types with the variable they are annotating.
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
},
{
"call-signature": "onespace",
"index-signature": "onespace",
"parameter": "onespace",
"property-declaration": "onespace",
"variable-declaration": "onespace"
}
],
// Functionality
// Don't use labels for evil.
"label-position": true,
// Use the logger configured by the project instead.
"no-console": [
true,
"log",
"info",
"warn",
"error",
"dir",
"time",
"timeEnd",
"trace",
"assert"
],
// new String('hi') !== 'hi' because JavaScript hates you.
"no-construct": true,
// Checking in statements that can block execution is generally bad.
"no-debugger": true,
// So rare that you need it these days; and it's so very fraught with peril.
"no-eval": true,
// Promises must be awaited (or then'd or caught) by default.
// When a promise should be kicked off and not awaited (rare),
// use void (e.g. `void promiseFn()`) to indicate this desire
// and opt out of this rule.
"no-floating-promises": true,
// Iterating over an array as if it were an object leads to all sorts of "fun".
// TODO: https://github.com/palantir/tslint/issues/1603
// "no-for-in-array": true,
// Shadowed variables can be pretty confusing.
"no-shadowed-variable": true,
// 99% of the time it's a mistake when you use fall through.
"no-switch-case-fall-through": true,
// Using control statements inside a finally block does crazy things.
"no-unsafe-finally": true,
// You probably forgot to call a method, or assign it to something.
// (Note - we use no-unused-expression-chai instead of no-unused-expression
// because it allows us to use chai statements like
// `expect(thing.do).to.be.ok;` without flagging them as violations.)
"no-unused-expression-chai": true,
// Hoisting is not really something we need to rely on.
"no-var-keyword": true,
// Implicit type coercion on maths is typically a bug.
//
// TODO: https://github.com/palantir/tslint/issues/1603
// "restrict-plus-operands": true
// ¯\_(ツ)_/¯
"triple-equals": [true, "allow-null-check"],
// NaN !== NaN.
"use-isnan": true,
// Maintainability
// So many tools bitch about missing newlines at the end of the file.
"eofline": true,
// Spaces. Two of them.
"indent": [true, "spaces"],
// Ideally: 80 characters for comments, 120 for code.
"max-line-length": [true, 120],
// Trailing whitespace clutters up diffs.
"no-trailing-whitespace": true,
// Use let as a hint to the reader that the value will change later.
"prefer-const": true,
// Enforcing trailing commas reduces noise in diffs and makes mass edits
// easier.
"trailing-comma": [true, { "multiline": "always", "singleline": "never" }],
// Style
// Always use `T[]` style syntax for array types.
"array-type": [true, "array"],
// CamelCaps class names.
"class-name": true,
// A space between // and your comment aids readability.
"comment-format": [true, "check-space"],
// Makes object construction a bit more consistent.
"new-parens": true,
// Always use `as T` style type assertions; because .tsx files won't let us
// have nice things.
"no-angle-bracket-type-assertion": true,
// NO.
"no-consecutive-blank-lines": [true, 1],
// Prefer `{ foo }` instead of `{ foo: foo }`.
"object-literal-shorthand": true,
// Opening and closing braces should be on the same line as statements.
//
// if (true) {
// …
// } else {
// …
// }
//
"one-line": [
true,
"check-catch",
"check-finally",
"check-else",
"check-open-brace",
"check-whitespace"
],
// Multi-variable declaratons tend to be very messy and hard to scan.
"one-variable-per-declaration": [true, "ignore-for-loop"],
// Save yourself some pain, and avoid ianm@ going OCD on your ass in PRs.
//
// You will probably want to turn on tslint auto fixing for your editor.
// TODO: Until we can figure out a better way of auto fixing for everyone.
// "ordered-imports": [true, {"import-sources-order": "case-insensitive"}],
// We prefer single quotes.
// TODO: We want to allow both single and backticks, but not double.
// "quotemark": [true, "single", "avoid-escape"],
// Why? Not sure these days, since "never" will still enforce semicolons in
// ambiguous cases, but it's what we do.
"semicolon": [true, "always"],
// Use camelCase for variable names.
"variable-name": [
true,
"check-format",
"allow-leading-underscore",
"ban-keywords",
"allow-pascal-case"
],
// Consistent whitespace around all the things!
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-module",
"check-separator",
"check-typecast"
]
}
}