UNPKG

13.8 kBJSONView Raw
1/**
2 * This "recommended" ruleset is considered legacy;
3 * it is generally preferable to extend from the 'recommended' or 'latest' rulesets.
4 * We recommend you instead explicitly include `tslint:recommended`, `tslint:latest`, or `tslint:all`
5 * in your `tslint.json` rather than enable core rules through this configuration.
6 *
7 * These rule settings are a broad, general recommendation for a good default configuration.
8 * This file is exported in the npm/nuget package as ./tslint.json.
9 */
10{
11 "rulesDirectory": ["./"],
12 "rules": {
13 /**
14 * Security Rules. The following rules should be turned on because they find security issues
15 * or are recommended in the Microsoft Secure Development Lifecycle (SDL)
16 */
17 "function-constructor": true,
18 "insecure-random": true,
19 "no-banned-terms": true,
20 "no-cookies": true,
21 "no-delete-expression": true,
22 "no-disable-auto-sanitization": true,
23 "no-document-domain": true,
24 "no-document-write": true,
25 "no-eval": true,
26 "no-exec-script": true,
27 "no-function-constructor-with-string-args": false, // use tslint function-constructor rule intsead
28 "no-http-string": [true, "http://www.example.com/?.*", "http://localhost:?.*"],
29 "no-inner-html": true,
30 "no-octal-literal": true,
31 "no-string-based-set-immediate": true,
32 "no-string-based-set-interval": true,
33 "no-string-based-set-timeout": true,
34 "non-literal-fs-path": true,
35 "non-literal-require": true,
36 "possible-timing-attack": true,
37 "react-anchor-blank-noopener": true,
38 "react-iframe-missing-sandbox": true,
39 "react-no-dangerous-html": true,
40
41 /**
42 * Common Bugs and Correctness. The following rules should be turned on because they find
43 * common bug patterns in the code or enforce type safety.
44 */
45 "await-promise": true,
46 "forin": true,
47 "increment-decrement": true,
48 "jquery-deferred-must-complete": true,
49 "label-position": true,
50 "match-default-export-name": true,
51 "mocha-avoid-only": true,
52 "mocha-no-side-effect-code": true,
53 "no-any": true,
54 "no-arg": true,
55 "no-backbone-get-set-outside-model": true,
56 "no-bitwise": true,
57 "no-conditional-assignment": true,
58 "no-console": [true, "debug", "info", "error", "log", "time", "timeEnd", "trace"],
59 "no-constant-condition": true,
60 "no-control-regex": true,
61 "no-debugger": true,
62 "no-duplicate-super": true,
63 "no-duplicate-switch-case": true,
64 "no-duplicate-variable": true,
65 "no-empty": true,
66 "no-floating-promises": true,
67 "no-for-in-array": true,
68 "no-implicit-dependencies": true,
69 "no-import-side-effect": true,
70 "no-increment-decrement": false, // use tslint increment-decrement rule instead
71 "no-invalid-regexp": true,
72 "no-invalid-template-strings": true,
73 "no-invalid-this": true,
74 "no-jquery-raw-elements": true,
75 "no-misused-new": true,
76 "no-non-null-assertion": true,
77 "no-object-literal-type-assertion": true,
78 "no-parameter-reassignment": true,
79 "no-reference-import": true,
80 "no-regex-spaces": true,
81 "no-sparse-arrays": true,
82 "no-string-literal": true,
83 "no-string-throw": true,
84 "no-submodule-imports": true,
85 "no-unnecessary-bind": false, // use tslint unnecessary-bind rule instead
86 "no-unnecessary-callback-wrapper": true,
87 "no-unnecessary-initializer": true,
88 "no-unnecessary-override": true,
89 "no-unsafe-any": true,
90 "no-unsafe-finally": true,
91 "no-unused-expression": true,
92 "no-use-before-declare": true,
93 "no-with-statement": true,
94 "promise-function-async": true,
95 "promise-must-complete": true,
96 "radix": true,
97 "react-this-binding-issue": true,
98 "react-unused-props-and-state": true,
99 "restrict-plus-operands": true, // the plus operand should really only be used for strings and numbers
100 "strict-boolean-expressions": true,
101 "switch-default": true,
102 "switch-final-break": true,
103 "triple-equals": [true, "allow-null-check"],
104 "unnecessary-bind": true,
105 "use-isnan": true,
106 "use-named-parameter": true,
107 "use-simple-attributes": true,
108
109 /**
110 * Code Clarity. The following rules should be turned on because they make the code
111 * generally more clear to the reader.
112 */
113 "adjacent-overload-signatures": true,
114 "array-type": [true, "array"],
115 "arrow-parens": false, // for simple functions the parens on arrow functions are not needed
116 "ban-comma-operator": true, // possibly controversial
117 "binary-expression-operand-order": true,
118 "callable-types": true,
119 "chai-prefer-contains-to-index-of": true,
120 "chai-vague-errors": true,
121 "class-name": true,
122 "comment-format": true,
123 "completed-docs": [true, "classes"],
124 "export-name": true,
125 "file-name-casing": true,
126 "function-name": true,
127 "import-name": true,
128 "informative-docs": true,
129 "interface-name": true,
130 "jsdoc-format": true,
131 "max-classes-per-file": [true, 3], // we generally recommend making one public class per file
132 "max-file-line-count": true,
133 "max-func-body-length": [true, 100, { "ignore-parameters-to-function-regex": "^describe$" }],
134 "max-line-length": [true, 140],
135 "member-access": true,
136 "member-ordering": [true, { "order": "fields-first" }],
137 "mocha-unneeded-done": true,
138 "new-parens": true,
139 "newline-per-chained-call": true,
140 "no-construct": true,
141 "no-default-export": true,
142 "no-duplicate-imports": true,
143 "no-dynamic-delete": true,
144 "no-empty-interface": true,
145 "no-for-in": true,
146 "no-function-expression": true,
147 "no-inferrable-types": false, // turn no-inferrable-types off in order to make the code consistent in its use of type decorations
148 "no-multiline-string": false,
149 "no-null-keyword": true,
150 "no-parameter-properties": true,
151 "no-redundant-jsdoc": true,
152 "no-relative-imports": true,
153 "no-require-imports": true,
154 "no-return-await": true,
155 "no-shadowed-variable": true,
156 "no-suspicious-comment": true,
157 "no-this-assignment": true,
158 "no-typeof-undefined": true,
159 "no-unnecessary-field-initialization": true,
160 "no-unnecessary-local-variable": true,
161 "no-unnecessary-qualifier": true,
162 "no-unnecessary-type-assertion": true,
163 "no-unsupported-browser-code": true,
164 "no-useless-files": true,
165 "no-var-keyword": true,
166 "no-var-requires": true,
167 "no-void-expression": true,
168 "number-literal-format": true,
169 "object-literal-sort-keys": false, // turn object-literal-sort-keys off and sort keys in a meaningful manner
170 "one-variable-per-declaration": true,
171 "only-arrow-functions": false, // there are many valid reasons to declare a function
172 "ordered-imports": true,
173 "prefer-array-literal": true,
174 "prefer-const": true,
175 "prefer-for-of": true,
176 "prefer-method-signature": true,
177 "prefer-object-spread": true,
178 "prefer-readonly": true,
179 "prefer-template": true,
180 "prefer-while": true,
181 "type-literal-delimiter": true,
182 "typedef": [true, "call-signature", "arrow-call-signature", "parameter", "arrow-parameter", "property-declaration", "variable-declaration", "member-variable-declaration"],
183 "underscore-consistent-invocation": true,
184 "unified-signatures": true,
185 "use-default-type-parameter": true,
186 "variable-name": true,
187 "void-zero": true,
188
189 /**
190 * Accessibility. The following rules should be turned on to guarantee the best user
191 * experience for keyboard and screen reader users.
192 */
193 "react-a11y-accessible-headings": true,
194 "react-a11y-anchors": true,
195 "react-a11y-aria-unsupported-elements": true,
196 "react-a11y-event-has-role": true,
197 "react-a11y-image-button-has-alt": true,
198 "react-a11y-img-has-alt": true,
199 "react-a11y-input-elements": true,
200 "react-a11y-lang": true,
201 "react-a11y-meta": true,
202 "react-a11y-no-onchange": true,
203 "react-a11y-props": true,
204 "react-a11y-proptypes": true,
205 "react-a11y-required": true,
206 "react-a11y-role": true,
207 "react-a11y-role-has-required-aria-props": true,
208 "react-a11y-role-supports-aria-props": true,
209 "react-a11y-tabindex-no-positive": true,
210 "react-a11y-titles": true,
211
212 /**
213 * Whitespace related rules. The only recommended whitespace strategy is to pick a single format and
214 * be consistent.
215 */
216 "align": [true, "parameters", "arguments", "statements"],
217 "curly": true,
218 "encoding": true,
219 "eofline": true,
220 "import-spacing": true,
221 "indent": [true, "spaces"],
222 "linebreak-style": true,
223 "newline-before-return": true,
224 "no-consecutive-blank-lines": true,
225 "no-empty-line-after-opening-brace": false,
226 "no-irregular-whitespace": true,
227 "no-single-line-block-comment": true,
228 "no-trailing-whitespace": true,
229 "no-unnecessary-semicolons": true,
230 "object-literal-key-quotes": [true, "as-needed"],
231 "one-line": [true, "check-open-brace", "check-catch", "check-else", "check-whitespace"],
232 "quotemark": [true, "single"],
233 "semicolon": [true, "always"],
234 "space-within-parens": true,
235 "trailing-comma": [true, { "singleline": "never", "multiline": "never" }], // forcing trailing commas for multi-line
236 // lists results in lists that are easier to reorder and version control diffs that are more clear.
237 // Many teams like to have multiline be "always". There is no clear consensus on this rule but the
238 // internal MS JavaScript coding standard does discourage it.
239 "typedef-whitespace": false,
240 "whitespace": [true, "check-branch", "check-decl", "check-operator", "check-separator", "check-type"],
241
242 /**
243 * Controversial/Configurable rules.
244 */
245 "ban": false, // only enable this if you have some code pattern that you want to ban
246 "ban-types": true,
247 "cyclomatic-complexity": true,
248 "deprecation": false, // deprecated APIs are sometimes unavoidable
249 "file-header": false, // enable this rule only if you are legally required to add a file header
250 "import-blacklist": false, // enable and configure this as you desire
251 "interface-over-type-literal": false, // there are plenty of reasons to prefer interfaces
252 "no-angle-bracket-type-assertion": false, // pick either type-cast format and use it consistently
253 "no-inferred-empty-object-type": false, // if the compiler is satisfied then this is probably not an issue
254 "no-internal-module": false, // only enable this if you are not using internal modules
255 "no-magic-numbers": false, // by default it will find too many false positives
256 "no-mergeable-namespace": false, // your project may require mergeable namespaces
257 "no-namespace": false, // only enable this if you are not using modules/namespaces
258 "no-reference": true, // in general you should use a module system and not /// reference imports
259 "no-unexternalized-strings": false, // the VS Code team has a specific localization process that this rule enforces
260 "object-literal-shorthand": false, // object-literal-shorthand offers an abbreviation not an abstraction
261 "prefer-conditional-expression": false, // unnecessarily strict
262 "prefer-switch": false, // more of a style preference
263 "prefer-type-cast": true, // pick either type-cast format and use it consistently
264 "return-undefined": false, // this actually affects the readability of the code
265 "space-before-function-paren": false, // turn this on if this is really your coding standard
266
267 /**
268 * Deprecated rules. The following rules are deprecated for various reasons.
269 */
270 "missing-jsdoc": false,
271 "missing-optional-annotation": false, // now supported by TypeScript compiler
272 "no-duplicate-case": false,
273 "no-duplicate-parameter-names": false, // now supported by TypeScript compiler
274 "no-empty-interfaces": false, // use tslint no-empty-interface rule instead
275 "no-missing-visibility-modifiers": false, // use tslint member-access rule instead
276 "no-multiple-var-decl": false, // use tslint one-variable-per-declaration rule instead
277 "no-reserved-keywords": false,
278 "no-stateless-class": false,
279 "no-switch-case-fall-through": false, // now supported by TypeScript compiler
280 "no-unnecessary-class": true,
281 "no-var-self": false,
282 "react-tsx-curly-spacing": false,
283 "typeof-compare": false, // the valid-typeof rule is currently superior to this version
284 "valid-typeof": false
285 }
286}