| 1 |
module.exports = { |
| 2 |
linterOptions: { |
| 3 |
exclude: ['node_modules', 'dist', 'coverage', 'dev'], |
| 4 |
}, |
| 5 |
rules: { |
| 6 |
/** |
| 7 |
* Enforces function overloads to be consecutive |
| 8 |
*/ |
| 9 |
'adjacent-overload-signatures': true, |
| 10 |
/** |
| 11 |
* Bans specific types from bening used. Does not |
| 12 |
* ban the corresponding runtime objects from being |
| 13 |
* used. |
| 14 |
*/ |
| 15 |
'ban-types': [ |
| 16 |
true, |
| 17 |
[ |
| 18 |
['Object', 'Avoid using the `Object` type. Did you mean `object`?'], |
| 19 |
[ |
| 20 |
'Function', |
| 21 |
'Avoid using the `Function` type. Prefer a specific function type, like `() => void`.', |
| 22 |
], |
| 23 |
['Boolean', 'Avoid using the `Boolean` type. Did you mean `boolean`?'], |
| 24 |
['Number', 'Avoid using the `Number` type. Did you mean `number`?'], |
| 25 |
['String', 'Avoid using the `String` type. Did you mean `string`?'], |
| 26 |
['Symbol', 'Avoid using the `Symbol` type. Did you mean `symbol`?'], |
| 27 |
], |
| 28 |
], |
| 29 |
/** |
| 30 |
* Disallows internal `module` |
| 31 |
*/ |
| 32 |
'no-internal-module': true, |
| 33 |
/** |
| 34 |
* Disallows reassigning function parameters |
| 35 |
*/ |
| 36 |
'no-parameter-reassignment': true, |
| 37 |
/** |
| 38 |
* Disallows `/// <reference path=>` imports |
| 39 |
* (use ES6-style imports instead) |
| 40 |
*/ |
| 41 |
'no-reference': true, |
| 42 |
/** |
| 43 |
* Warns if a type assertion does not change |
| 44 |
* the type of an expression |
| 45 |
*/ |
| 46 |
'no-unnecessary-type-assertion': true, |
| 47 |
/** |
| 48 |
* Disallows traditional (non-arrow) function expressions. |
| 49 |
*/ |
| 50 |
'only-arrow-functions': [ |
| 51 |
true, |
| 52 |
'allow-declarations', |
| 53 |
'allow-named-functions', |
| 54 |
], |
| 55 |
/** |
| 56 |
* Recommends a ‘for-of’ loop over a standard ‘for’ loop |
| 57 |
* if the index is only used to access the array being |
| 58 |
* iterated. |
| 59 |
*/ |
| 60 |
'prefer-for-of': true, |
| 61 |
/** |
| 62 |
* Requires any function or method that returns a promise |
| 63 |
* to be marked async. |
| 64 |
*/ |
| 65 |
'promise-function-async': true, |
| 66 |
/** |
| 67 |
* Warns for any two overloads that could be unified into |
| 68 |
* one by using a union or an optional/rest parameter. |
| 69 |
*/ |
| 70 |
'unified-signatures': false, // disabled because there are some cases that it gets wrong |
| 71 |
/** |
| 72 |
* Warns for an awaited value that is not a Promise. |
| 73 |
*/ |
| 74 |
'await-promise': true, |
| 75 |
/** |
| 76 |
* Disallows the comma operator to be used. |
| 77 |
*/ |
| 78 |
'ban-comma-operator': true, |
| 79 |
/** |
| 80 |
* Disallows bitwise operators. |
| 81 |
*/ |
| 82 |
'no-bitwise': true, |
| 83 |
/** |
| 84 |
* Disallows any type of assignment in conditionals. |
| 85 |
*/ |
| 86 |
'no-conditional-assignment': true, |
| 87 |
/** |
| 88 |
* Bans the use of console.log and console.dir. |
| 89 |
* It's fine to use these while debugging, but they |
| 90 |
* should not be committed. |
| 91 |
*/ |
| 92 |
'no-console': [true, 'log', 'dir'], // use `console.info` if the log is intentional |
| 93 |
/** |
| 94 |
* Disallows access to the constructors of `String`, |
| 95 |
* `Number`, and `Boolean`. |
| 96 |
* |
| 97 |
* Disallows constructor use such as `new Number(foo)` |
| 98 |
* but does not disallow `Number(foo)`. |
| 99 |
*/ |
| 100 |
'no-construct': true, |
| 101 |
/** |
| 102 |
* Disallows `debugger;` statements. |
| 103 |
* |
| 104 |
* These are fine to use in development, but should not |
| 105 |
* be committed. |
| 106 |
*/ |
| 107 |
'no-debugger': true, |
| 108 |
/** |
| 109 |
* Warns if `super()` appears twice in a constructor. |
| 110 |
*/ |
| 111 |
'no-duplicate-super': true, |
| 112 |
/** |
| 113 |
* Prevents duplicate cases in switch statements. |
| 114 |
*/ |
| 115 |
'no-duplicate-switch-case': true, |
| 116 |
/** |
| 117 |
* Disallows duplicate variable declarations in |
| 118 |
* the same block scope. |
| 119 |
*/ |
| 120 |
'no-duplicate-variable': true, |
| 121 |
/** |
| 122 |
* Disallows empty blocks. |
| 123 |
* |
| 124 |
* Blocks with a comment inside are not considered empty. |
| 125 |
*/ |
| 126 |
'no-empty': true, |
| 127 |
/** |
| 128 |
* Disallows `eval` function invocations. |
| 129 |
*/ |
| 130 |
'no-eval': true, |
| 131 |
/** |
| 132 |
* Promises returned by functions must be handled |
| 133 |
* appropriately. |
| 134 |
* |
| 135 |
* Unhandled Promises can cause unexpected behavior, |
| 136 |
* such as resolving at unexpected times. |
| 137 |
*/ |
| 138 |
'no-floating-promises': true, |
| 139 |
/** |
| 140 |
* Disallows iterating over an array with a for-in loop. |
| 141 |
*/ |
| 142 |
'no-for-in-array': true, |
| 143 |
/** |
| 144 |
* Disallows importing modules that are not listed as |
| 145 |
* dependency in the project’s package.json |
| 146 |
* |
| 147 |
* Disallows importing transient dependencies and modules |
| 148 |
* installed above your package’s root directory. |
| 149 |
*/ |
| 150 |
'no-implicit-dependencies': [true, 'dev', 'optional'], |
| 151 |
/** |
| 152 |
* Warns on use of `${` in non-template strings. |
| 153 |
*/ |
| 154 |
'no-invalid-template-strings': true, |
| 155 |
/** |
| 156 |
* Disallows using the `this` keyword outside of classes. |
| 157 |
*/ |
| 158 |
'no-invalid-this': true, |
| 159 |
/** |
| 160 |
* Warns on apparent attempts to define constructors for |
| 161 |
* interfaces or new for classes. |
| 162 |
*/ |
| 163 |
'no-misused-new': true, |
| 164 |
/** |
| 165 |
* Forbids an object literal to appear in a type assertion |
| 166 |
* expression. Casting to `any` is still allowed. |
| 167 |
* |
| 168 |
* Disabled because it prevents using the new `as const` syntax |
| 169 |
*/ |
| 170 |
'no-object-literal-type-assertion': false, |
| 171 |
/** |
| 172 |
* Disallows shadowing variable declarations. |
| 173 |
*/ |
| 174 |
'no-shadowed-variable': false, // disabled because I find it super annoying |
| 175 |
/** |
| 176 |
* Forbids array literals to contain missing elements. |
| 177 |
*/ |
| 178 |
'no-sparse-arrays': true, |
| 179 |
/** |
| 180 |
* Forbids unnecessary string literal property access. |
| 181 |
* Allows `obj["prop-erty"]` (can’t be a regular property |
| 182 |
* access). Disallows `obj["property"]` (should be |
| 183 |
* `obj.property`). |
| 184 |
*/ |
| 185 |
'no-string-literal': true, |
| 186 |
/** |
| 187 |
* Disallows falling through case statements. |
| 188 |
*/ |
| 189 |
'no-switch-case-fall-through': true, |
| 190 |
/** |
| 191 |
* Disallows unnecessary references to `this`. |
| 192 |
* |
| 193 |
* Use arrow functions instead. |
| 194 |
*/ |
| 195 |
'no-this-assignment': true, |
| 196 |
/** |
| 197 |
* Warns when a method is used outside of a |
| 198 |
* method call. |
| 199 |
* |
| 200 |
* Use arrow function properties instead. |
| 201 |
*/ |
| 202 |
'no-unbound-method': [true, 'ignore-static'], |
| 203 |
/** |
| 204 |
* Disallows classes that are not strictly necessary. |
| 205 |
*/ |
| 206 |
'no-unnecessary-class': true, |
| 207 |
/** |
| 208 |
* Disallows control flow statements, such as `return`, |
| 209 |
* `continue`, `break` and `throw` in finally blocks. |
| 210 |
*/ |
| 211 |
'no-unsafe-finally': true, |
| 212 |
/** |
| 213 |
* Disallows unused expression statements. |
| 214 |
* |
| 215 |
* Unused expressions are expression statements which are |
| 216 |
* not assignments or function calls (and thus usually no-ops). |
| 217 |
* |
| 218 |
* We allow `e && e.preventDefault();` as a short hand for |
| 219 |
* `if (e) e.preventDefault();` |
| 220 |
*/ |
| 221 |
'no-unused-expression': [true, 'allow-fast-null-checks'], |
| 222 |
/** |
| 223 |
* Disallows usage of the `var` keyword. |
| 224 |
* |
| 225 |
* Use `let` or `const` instead. |
| 226 |
*/ |
| 227 |
'no-var-keyword': true, |
| 228 |
/** |
| 229 |
* Requires expressions of type void to |
| 230 |
* appear in statement position. |
| 231 |
*/ |
| 232 |
'no-void-expression': [true, 'ignore-arrow-function-shorthand'], |
| 233 |
/** |
| 234 |
* Requires the radix parameter to be |
| 235 |
* specified when calling `parseInt`. |
| 236 |
*/ |
| 237 |
radix: true, |
| 238 |
/** |
| 239 |
* When adding two variables, operands must both |
| 240 |
* be of type number or of type string. |
| 241 |
*/ |
| 242 |
'restrict-plus-operands': true, |
| 243 |
/** |
| 244 |
* Warns for type predicates that are always true |
| 245 |
* or always false. Works for ‘typeof’ comparisons |
| 246 |
* to constants (e.g. ‘typeof foo === “string”’), |
| 247 |
* and equality comparison to ‘null’/’undefined’. |
| 248 |
* (TypeScript won’t let you compare ‘1 === 2’, |
| 249 |
* but it has an exception for ‘1 === undefined’.) |
| 250 |
* Does not yet work for ‘instanceof’. Does not |
| 251 |
* warn for ‘if (x.y)’ where ‘x.y’ is always truthy. |
| 252 |
* For that, see strict-boolean-expressions. |
| 253 |
* |
| 254 |
* This rule requires strictNullChecks to work properly. |
| 255 |
*/ |
| 256 |
'strict-type-predicates': true, |
| 257 |
/** |
| 258 |
* Requires `===` and `!==` in place of `==` and `!=` |
| 259 |
* |
| 260 |
* Also allows `== null` and `!= null` as a shorthand |
| 261 |
* for `x === null || x === undefined` and `x !== null || x !== undefined` |
| 262 |
*/ |
| 263 |
'triple-equals': [true, 'allow-null-check'], |
| 264 |
/** |
| 265 |
* Enforces use of the isNaN() function to check for |
| 266 |
* NaN references instead of a comparison to the NaN |
| 267 |
* constant. |
| 268 |
*/ |
| 269 |
'use-isnan': true, |
| 270 |
/** |
| 271 |
* Warns when deprecated APIs are used. |
| 272 |
* |
| 273 |
* Any usage of an identifier with the `[at]deprecated` JSDoc |
| 274 |
* annotation will trigger a warning. See: |
| 275 |
* http://usejsdoc.org/tags-deprecated.html |
| 276 |
*/ |
| 277 |
deprecation: true, |
| 278 |
/** |
| 279 |
* Disallows multiple import statements from the same module. |
| 280 |
*/ |
| 281 |
'no-duplicate-imports': true, |
| 282 |
/** |
| 283 |
* Disallows mergeable namespaces in the same file. |
| 284 |
*/ |
| 285 |
'no-mergeable-namespace': true, |
| 286 |
/** |
| 287 |
* Requires that variable declarations use `const` instead of |
| 288 |
* `let` and `var` if possible. |
| 289 |
* |
| 290 |
* If a variable is only assigned to once when it is declared, |
| 291 |
* it should be declared using `const` |
| 292 |
*/ |
| 293 |
'prefer-const': true, |
| 294 |
/** |
| 295 |
* Requires that private variables are marked as `readonly` |
| 296 |
* if they’re never modified outside of the constructor. |
| 297 |
* |
| 298 |
* If a private variable is only assigned to in the constructor, |
| 299 |
* it should be declared as `readonly`. |
| 300 |
*/ |
| 301 |
'prefer-readonly': true, |
| 302 |
/** |
| 303 |
* An interface or literal type with just a call signature can |
| 304 |
* be written as a function type. |
| 305 |
*/ |
| 306 |
'callable-types': true, |
| 307 |
/** |
| 308 |
* Enforces PascalCased class and interface names. |
| 309 |
*/ |
| 310 |
'class-name': true, |
| 311 |
/** |
| 312 |
* Enforces UTF-8 file encoding. |
| 313 |
*/ |
| 314 |
encoding: true, |
| 315 |
/** |
| 316 |
* Enforces basic whitespace formatting rules for |
| 317 |
* JSDoc comments. |
| 318 |
*/ |
| 319 |
'jsdoc-format': true, |
| 320 |
/** |
| 321 |
* Requires the use of `as Type` for type assertions instead of `<Type>`. |
| 322 |
*/ |
| 323 |
'no-angle-bracket-type-assertion': true, |
| 324 |
/** |
| 325 |
* Disallows parameter properties in class constructors. |
| 326 |
*/ |
| 327 |
'no-parameter-properties': true, |
| 328 |
/** |
| 329 |
* Forbids JSDoc which duplicates TypeScript functionality. |
| 330 |
*/ |
| 331 |
'no-redundant-jsdoc': true, |
| 332 |
/** |
| 333 |
* Don’t <reference types="foo" /> if you import foo anyway. |
| 334 |
*/ |
| 335 |
'no-reference-import': true, |
| 336 |
/** |
| 337 |
* Forbids a ‘var’/’let’ statement or destructuring initializer |
| 338 |
* to be initialized to ‘undefined’. |
| 339 |
*/ |
| 340 |
'no-unnecessary-initializer': true, |
| 341 |
/** |
| 342 |
* Disallows multiple variable definitions in the same declaration statement. |
| 343 |
*/ |
| 344 |
'one-variable-per-declaration': true, |
| 345 |
/** |
| 346 |
* Prefer while loops instead of for loops |
| 347 |
* without an initializer and incrementor. |
| 348 |
*/ |
| 349 |
'prefer-while': true, |
| 350 |
/** |
| 351 |
* Prefer `return;` in void functions and |
| 352 |
* `return undefined;` in value-returning |
| 353 |
* functions. |
| 354 |
*/ |
| 355 |
'return-undefined': true, |
| 356 |
/** |
| 357 |
* Checks whether the final clause of a |
| 358 |
* `switch` statement ends in `break;`. |
| 359 |
*/ |
| 360 |
'switch-final-break': [true, 'always'], |
| 361 |
/** |
| 362 |
* Disallows variable names like `any`, `Number`, `string` etc. |
| 363 |
*/ |
| 364 |
'variable-name': [true, 'ban-keywords'], |
| 365 |
|
| 366 |
/** |
| 367 |
* Enforces that class members that are public are explicitly marked `public`. |
| 368 |
*/ |
| 369 |
'member-access': true, |
| 370 |
}, |
| 371 |
}; |