|
| 1 | +{ |
| 2 | + "extends": ["tslint:latest", "tslint-eslint-rules"], |
| 3 | + "linterOptions": { |
| 4 | + "exclude": [ |
| 5 | + "node_modules", |
| 6 | + "*.d.ts" |
| 7 | + ] |
| 8 | + }, |
| 9 | + "rules": { |
| 10 | + "adjacent-overload-signatures": true, |
| 11 | + "align": [true, "members", "parameters", "statements"], |
| 12 | + "array-bracket-spacing": [true, "never", {"singleValue": false, "objectsInArrays": true, "arraysInArrays": true} ], // 设置在括号内使用空格风格 |
| 13 | + "arrow-parens": [true, "ban-single-arg-parens"], |
| 14 | + "await-promise": [true, "Thenable"], // Warns for an awaited value that is not a Promise. |
| 15 | + "ban-comma-operator": true, |
| 16 | + "block-spacing": [true, "always"], // 强制在单行代码块中使用一致的空格 |
| 17 | + "brace-style": [true, "stroustrup", { "allowSingleLine": true }], // 大括号风格要求 |
| 18 | + "comment-format": [true, "check-space", {"ignore-words": ["-", "+"]}], // 强制在注释中 // 或 /* 使用一致的空格 |
| 19 | + "curly": [true, "ignore-same-line"], // 要求遵循大括号约定 |
| 20 | + "eofline": true, |
| 21 | + "forin": false, |
| 22 | + "import-blacklist": [ |
| 23 | + true, |
| 24 | + "rxjs", |
| 25 | + "rxjs/Rx" |
| 26 | + ], |
| 27 | + "indent": [true, "spaces", 2], |
| 28 | + "interface-name": [ false, "never-prefix" ], |
| 29 | + "linebreak-style": [true , "LF" ], |
| 30 | + "max-classes-per-file": [ true, 10 ], |
| 31 | + "max-line-length": [true, 120], |
| 32 | + "member-access": [ false ], |
| 33 | + "member-ordering": [true, {"order": [ |
| 34 | + "public-static-field", |
| 35 | + "public-instance-field", |
| 36 | + "public-constructor", |
| 37 | + "private-static-field", |
| 38 | + "private-instance-field", |
| 39 | + "private-constructor", |
| 40 | + "public-instance-method", |
| 41 | + "protected-instance-method", |
| 42 | + "private-instance-method" |
| 43 | + ]}], |
| 44 | + "no-arg": true, |
| 45 | + "no-angle-bracket-type-assertion": false, |
| 46 | + "no-consecutive-blank-lines": [true, 4], // 多个空行控制 |
| 47 | + "no-console": [ true, "dir", "log", "warn" ], |
| 48 | + "no-construct": true, // 禁止对 String,Number 和 Boolean 使用 new 操作符 |
| 49 | + "no-control-regex": true, |
| 50 | + "no-duplicate-variable": true, |
| 51 | + "no-duplicate-imports": true, // 禁止单个模块多次导入 |
| 52 | + "no-duplicate-switch-case": true, |
| 53 | + "no-empty": false, // 禁止空块语句 |
| 54 | + "no-extra-semi": true, |
| 55 | + "no-eval": true, |
| 56 | + "no-implicit-dependencies": [true, "dev"], |
| 57 | + "no-multi-spaces": [ true, { "exceptions": { "PropertyAssignment": true, "VariableDeclaration": false } } ] , // 禁止出现多个空格 |
| 58 | + "no-object-literal-type-assertion": false, |
| 59 | + "no-parameter-reassignment": false, // 禁止参数变量重新赋值 |
| 60 | + "no-return-await": true, |
| 61 | + "no-reference": true, // Disallows /// <reference path=> imports (use ES6-style imports instead). |
| 62 | + "no-shadowed-variable": [ |
| 63 | + true, |
| 64 | + { |
| 65 | + "class": true, |
| 66 | + "enum": true, |
| 67 | + "function": true, |
| 68 | + "interface": true, |
| 69 | + "namespace": true, |
| 70 | + "typeAlias": true, |
| 71 | + "typeParameter": true |
| 72 | + } |
| 73 | + ], |
| 74 | + "no-string-throw": true, |
| 75 | + "no-submodule-imports": [true, |
| 76 | + "rxjs", |
| 77 | + "@angular/platform-browser", |
| 78 | + "source-map-support/register" |
| 79 | + ], |
| 80 | + "no-trailing-whitespace": [true, "ignore-comments"], // 禁用行尾空白 |
| 81 | + "no-unnecessary-initializer": true, // 禁止变量赋值为 undefined |
| 82 | + "no-unused-expression": [true, "allow-fast-null-checks"], |
| 83 | + "no-unused-variable": { |
| 84 | + "severity": "warning", |
| 85 | + "options": [true, { "ignore-pattern": "^_" }] |
| 86 | + }, |
| 87 | + "no-unnecessary-type-assertion": false, |
| 88 | + "no-use-before-declare": true, // 禁止在变量定义之前使用它们 |
| 89 | + "no-var-keyword": true, // 要求使用 let 或 const 而不是 var |
| 90 | + "no-var-requires": true, // Disallows the use of require statements except in import statements. |
| 91 | + "object-curly-spacing": [true, "always"], // 强制在大括号中使用一致的空格 |
| 92 | + "object-literal-shorthand": [true], |
| 93 | + "object-literal-sort-keys": false, |
| 94 | + "one-line": [true, "check-open-brace", "check-whitespace"], |
| 95 | + "ordered-imports": [ |
| 96 | + true, |
| 97 | + { |
| 98 | + "grouped-imports": true, |
| 99 | + "import-sources-order": "lowercase-last", |
| 100 | + "named-imports-order": "lowercase-first" |
| 101 | + } |
| 102 | + ], |
| 103 | + "prefer-for-of": true, |
| 104 | + "quotemark": [true, "single", "avoid-escape", "avoid-template"], |
| 105 | + "radix": true, |
| 106 | + "semicolon": [true, "never"], |
| 107 | + "space-before-function-paren": [ |
| 108 | + true, |
| 109 | + {"anonymous": "always", "named": "never"} |
| 110 | + ], |
| 111 | + "ter-arrow-spacing": [true, { "before": true, "after": true }], // 要求箭头函数的箭头之前或之后有空格 |
| 112 | + "ter-func-call-spacing": [true, "never"], // disallow spacing between function identifiers and their invocations |
| 113 | + "ter-indent": [true, 2, |
| 114 | + { |
| 115 | + "SwitchCase": 1 |
| 116 | + } |
| 117 | + ], |
| 118 | + "ter-no-irregular-whitespace": true, // 禁止不规则的空白 |
| 119 | + "trailing-comma": [true, |
| 120 | + { |
| 121 | + "multiline": { |
| 122 | + "arrays": "always", |
| 123 | + "exports": "always", |
| 124 | + "imports": "always", |
| 125 | + "functions": "never", |
| 126 | + "objects": "always", |
| 127 | + "typeLiterals": "always" |
| 128 | + }, |
| 129 | + "singleline": "never", |
| 130 | + "esSpecCompliant": true |
| 131 | + } |
| 132 | + ], // 当最后一个元素或属性与闭括号 ] 或 右大括号 在 不同的行时,要求使用拖尾逗号;当在 同一行时,禁止使用拖尾逗号 |
| 133 | + "triple-equals": true, |
| 134 | + "use-isnan": true, // 要求使用 isNaN() 检查 NaN |
| 135 | + "valid-typeof": true, // 强制 typeof 表达式与有效的字符串进行比较 |
| 136 | + "variable-name": [true, "ban-keywords", "allow-leading-underscore"], |
| 137 | + "whitespace": { |
| 138 | + "options": [true, |
| 139 | + "check-branch", |
| 140 | + "check-decl", |
| 141 | + "check-operator", |
| 142 | + "check-module", |
| 143 | + "check-separator", |
| 144 | + "check-rest-spread", |
| 145 | + "check-type", |
| 146 | + "check-typecast", |
| 147 | + "check-type-operator", |
| 148 | + "check-preblock"] |
| 149 | + } |
| 150 | + } |
| 151 | +} |
0 commit comments