|
| 1 | +{ |
| 2 | + "rules": { |
| 3 | + // -- Strict errors -- |
| 4 | + // These lint rules are likely always a good idea. |
| 5 | + |
| 6 | + // Force function overloads to be declared together. This ensures readers understand APIs. |
| 7 | + "adjacent-overload-signatures": true, |
| 8 | + |
| 9 | + // Do not allow the subtle/obscure comma operator. |
| 10 | + "ban-comma-operator": true, |
| 11 | + |
| 12 | + // Do not allow internal modules or namespaces . These are deprecated in favor of ES6 modules. |
| 13 | + "no-namespace": true, |
| 14 | + |
| 15 | + // Do not allow parameters to be reassigned. To avoid bugs, developers should instead assign new values to new vars. |
| 16 | + "no-parameter-reassignment": true, |
| 17 | + |
| 18 | + // Force the use of ES6-style imports instead of /// <reference path=> imports. |
| 19 | + "no-reference": true, |
| 20 | + |
| 21 | + // Do not allow type assertions that do nothing. This is a big warning that the developer may not understand the |
| 22 | + // code currently being edited (they may be incorrectly handling a different type case that does not exist). |
| 23 | + "no-unnecessary-type-assertion": true, |
| 24 | + |
| 25 | + // Disallow nonsensical label usage. |
| 26 | + "label-position": true, |
| 27 | + |
| 28 | + // Disallows the (often typo) syntax if (var1 = var2). Replace with if (var2) { var1 = var2 }. |
| 29 | + "no-conditional-assignment": true, |
| 30 | + |
| 31 | + // Disallows constructors for primitive types (e.g. new Number('123'), though Number('123') is still allowed). |
| 32 | + "no-construct": true, |
| 33 | + |
| 34 | + // Do not allow super() to be called twice in a constructor. |
| 35 | + "no-duplicate-super": true, |
| 36 | + |
| 37 | + // Do not allow the same case to appear more than once in a switch block. |
| 38 | + "no-duplicate-switch-case": true, |
| 39 | + |
| 40 | + // Do not allow a variable to be declared more than once in the same block. Consider function parameters in this |
| 41 | + // rule. |
| 42 | + "no-duplicate-variable": [true, "check-parameters"], |
| 43 | + |
| 44 | + // Disallows a variable definition in an inner scope from shadowing a variable in an outer scope. Developers should |
| 45 | + // instead use a separate variable name. |
| 46 | + "no-shadowed-variable": true, |
| 47 | + |
| 48 | + // Empty blocks are almost never needed. Allow the one general exception: empty catch blocks. |
| 49 | + "no-empty": [true, "allow-empty-catch"], |
| 50 | + |
| 51 | + // Functions must either be handled directly (e.g. with a catch() handler) or returned to another function. |
| 52 | + // This is a major source of errors in Cloud Functions and the team strongly recommends leaving this rule on. |
| 53 | + "no-floating-promises": true, |
| 54 | + |
| 55 | + // Do not allow any imports for modules that are not in package.json. These will almost certainly fail when |
| 56 | + // deployed. |
| 57 | + "no-implicit-dependencies": true, |
| 58 | + |
| 59 | + // The 'this' keyword can only be used inside of classes. |
| 60 | + "no-invalid-this": true, |
| 61 | + |
| 62 | + // Do not allow strings to be thrown because they will not include stack traces. Throw Errors instead. |
| 63 | + "no-string-throw": true, |
| 64 | + |
| 65 | + // Disallow control flow statements, such as return, continue, break, and throw in finally blocks. |
| 66 | + "no-unsafe-finally": true, |
| 67 | + |
| 68 | + // Expressions must always return a value. Avoids common errors like const myValue = functionReturningVoid(); |
| 69 | + "no-void-expression": [true, "ignore-arrow-function-shorthand"], |
| 70 | + |
| 71 | + // Disallow duplicate imports in the same file. |
| 72 | + "no-duplicate-imports": true, |
| 73 | + |
| 74 | + |
| 75 | + // -- Strong Warnings -- |
| 76 | + // These rules should almost never be needed, but may be included due to legacy code. |
| 77 | + // They are left as a warning to avoid frustration with blocked deploys when the developer |
| 78 | + // understand the warning and wants to deploy anyway. |
| 79 | + |
| 80 | + // Warn when an empty interface is defined. These are generally not useful. |
| 81 | + "no-empty-interface": {"severity": "warning"}, |
| 82 | + |
| 83 | + // Warn when an import will have side effects. |
| 84 | + "no-import-side-effect": {"severity": "warning"}, |
| 85 | + |
| 86 | + // Warn when variables are defined with var. Var has subtle meaning that can lead to bugs. Strongly prefer const for |
| 87 | + // most values and let for values that will change. |
| 88 | + "no-var-keyword": {"severity": "warning"}, |
| 89 | + |
| 90 | + // Prefer === and !== over == and !=. The latter operators support overloads that are often accidental. |
| 91 | + "triple-equals": {"severity": "warning"}, |
| 92 | + |
| 93 | + // Warn when using deprecated APIs. |
| 94 | + "deprecation": {"severity": "warning"}, |
| 95 | + |
| 96 | + // -- Light Warnings -- |
| 97 | + // These rules are intended to help developers use better style. Simpler code has fewer bugs. These would be "info" |
| 98 | + // if TSLint supported such a level. |
| 99 | + |
| 100 | + // prefer for( ... of ... ) to an index loop when the index is only used to fetch an object from an array. |
| 101 | + // (Even better: check out utils like .map if transforming an array!) |
| 102 | + "prefer-for-of": {"severity": "warning"}, |
| 103 | + |
| 104 | + // Warns if function overloads could be unified into a single function with optional or rest parameters. |
| 105 | + "unified-signatures": {"severity": "warning"}, |
| 106 | + |
| 107 | + // Prefer const for values that will not change. This better documents code. |
| 108 | + "prefer-const": {"severity": "warning"}, |
| 109 | + |
| 110 | + // Multi-line object literals and function calls should have a trailing comma. This helps avoid merge conflicts. |
| 111 | + "trailing-comma": {"severity": "warning"} |
| 112 | + }, |
| 113 | + |
| 114 | + "defaultSeverity": "error" |
| 115 | +} |
0 commit comments