tslint-meta.json 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. {
  2. "adjacent-overload-signatures": {
  3. "category": "typescript-specific",
  4. "description": "重载的函数必须写在一起",
  5. "ts-only": true
  6. },
  7. "ban-types": {
  8. "category": "typescript-specific",
  9. "description": "禁用特定的类型",
  10. "reason": "该规则用于禁止某个具体的类型的使用",
  11. "ts-only": true
  12. },
  13. "member-access": {
  14. "category": "typescript-specific",
  15. "description": "必须设置类的成员的可访问性",
  16. "reason": "将不需要公开的成员设为私有的,可以增强代码的可理解性,对文档输出也很友好",
  17. "ts-only": true,
  18. "has-fixer": true
  19. },
  20. "member-ordering": {
  21. "category": "typescript-specific",
  22. "description": "指定类成员的排序规则",
  23. "reason": "优先级:\n1. `static` > `instance`\n2. `field` > `constructor` > `method`\n3. `public` > `protected` > `private`",
  24. "has-fixer": true
  25. },
  26. "no-any": {
  27. "category": "typescript-specific",
  28. "description": "禁止使用 `any`",
  29. "reason": "太严格了",
  30. "ts-only": true
  31. },
  32. "no-empty-interface": {
  33. "category": "typescript-specific",
  34. "description": "禁止定义空的接口",
  35. "ts-only": true
  36. },
  37. "no-import-side-effect": {
  38. "category": "typescript-specific",
  39. "description": "禁止导入有副作用(立即执行)的模块,除了 `css`, `less`, `sass`, `scss`",
  40. "reason": "有副作用(立即执行)的模块无法控制其执行过程"
  41. },
  42. "no-inferrable-types": {
  43. "category": "typescript-specific",
  44. "description": "禁止给一个初始化时直接赋值为 `number`, `string` 或 `boolean` 的变量显式的指定类型",
  45. "reason": "可以简化代码,并且支持自动修复",
  46. "ts-only": true,
  47. "has-fixer": true
  48. },
  49. "no-internal-module": {
  50. "category": "typescript-specific",
  51. "description": "禁止使用 `module` 来定义命名空间",
  52. "reason": "`module` 已成为 js 的关键字",
  53. "ts-only": true,
  54. "has-fixer": true
  55. },
  56. "no-magic-numbers": {
  57. "category": "typescript-specific",
  58. "description": "禁止使用魔法数字,仅允许使用一部分白名单中的数字",
  59. "reason": "魔法数字无法理解"
  60. },
  61. "no-namespace": {
  62. "category": "typescript-specific",
  63. "description": "禁止使用 `namespace` 来定义命名空间",
  64. "reason": "使用 es6 引入模块,才是更标准的方式。\n允许使用 `declare namespace ... {}` 来定义外部命名空间",
  65. "ts-only": true
  66. },
  67. "no-non-null-assertion": {
  68. "category": "typescript-specific",
  69. "description": "禁止使用 non-null 断言(感叹号)",
  70. "reason": "non-null 断言不安全,最好使用条件语句把 `null` 排除掉比较好",
  71. "ts-only": true
  72. },
  73. "no-parameter-reassignment": {
  74. "category": "typescript-specific",
  75. "description": "禁止对函数的参数重新赋值"
  76. },
  77. "no-reference": {
  78. "category": "typescript-specific",
  79. "description": "禁止使用三斜线引入模块 `/// <reference path=\"foo\" />`",
  80. "reason": "引入模块时应使用更先进的 `import` 语法\n三斜线仅能用于引入一个类型文件 `/// <reference types=\"foo\" />`"
  81. },
  82. "no-unnecessary-type-assertion": {
  83. "category": "typescript-specific",
  84. "description": "禁止无用的类型断言",
  85. "reason": "Requires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  86. "ts-only": true,
  87. "has-fixer": true,
  88. "requires-type-info": true
  89. },
  90. "no-var-requires": {
  91. "category": "typescript-specific",
  92. "description": "禁止使用 `require` 来引入模块",
  93. "reason": "统一使用 `import` 来引入模块,特殊情况使用单行注释允许 `require` 引入",
  94. "ts-only": true
  95. },
  96. "only-arrow-functions": {
  97. "category": "typescript-specific",
  98. "description": "必须使用箭头函数,除非是单独的函数声明或是命名函数",
  99. "reason": "统一使用箭头函数,避免 `this` 指向问题"
  100. },
  101. "prefer-for-of": {
  102. "category": "typescript-specific",
  103. "description": "使用 `for` 循环遍历数组时,如果 `index` 仅用于获取成员,则必须使用 `for of` 循环替代 `for` 循环",
  104. "reason": "`for of` 循环更加易读"
  105. },
  106. "promise-function-async": {
  107. "category": "typescript-specific",
  108. "description": "`async` 函数的返回值必须是 `Promise`",
  109. "reason": "有时 `async` 函数在某个分支是同步的,不需要返回 `Promise`\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  110. "requires-type-info": true
  111. },
  112. "typedef": {
  113. "category": "typescript-specific",
  114. "description": "变量、函数返回值、函数参数等必须要有类型定义",
  115. "reason": "大部分类型都可以依靠类型推论,没必要全部手动定义",
  116. "ts-only": true
  117. },
  118. "typedef-whitespace": {
  119. "category": "typescript-specific",
  120. "description": "类型定义的冒号前面必须没有空格,后面必须有一个空格",
  121. "ts-only": true,
  122. "has-fixer": true,
  123. "prettier": true
  124. },
  125. "unified-signatures": {
  126. "category": "typescript-specific",
  127. "description": "函数重载时,若能通过联合类型将两个函数的类型声明合为一个,则使用联合类型而不是两个函数声明",
  128. "ts-only": true
  129. },
  130. "await-promise": {
  131. "category": "functionality",
  132. "description": "`await` 必须接受 `Promise`",
  133. "reason": "promise-function-async 里已经允许 `async` 函数返回值为非 `Promise` 了,故也应该允许 `await` 接受非 `Promise`\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  134. "ts-only": true,
  135. "requires-type-info": true
  136. },
  137. "ban": {
  138. "category": "functionality",
  139. "description": "禁用指定的函数或全局方法",
  140. "reason": "用于限制某个具体的函数不能使用"
  141. },
  142. "ban-comma-operator": { "category": "functionality", "description": "禁止使用逗号操作符" },
  143. "curly": {
  144. "category": "functionality",
  145. "description": "`if` 后面必须有 `{`,除非是单行 `if`",
  146. "has-fixer": true
  147. },
  148. "forin": { "category": "functionality", "description": "`for in` 内部必须有 `hasOwnProperty`" },
  149. "import-blacklist": {
  150. "category": "functionality",
  151. "description": "禁用指定的模块",
  152. "reason": "用于限制某个具体的模块不能使用"
  153. },
  154. "label-position": {
  155. "category": "functionality",
  156. "description": "只允许在 `do`, `for`, `while` 或 `switch` 中使用 `label`",
  157. "reason": "在任何情况都不应该使用 `label`"
  158. },
  159. "no-arg": { "category": "functionality", "description": "禁止使用 `arguments.callee`" },
  160. "no-bitwise": {
  161. "category": "functionality",
  162. "description": "禁止使用位运算",
  163. "reason": "位运算很常见"
  164. },
  165. "no-conditional-assignment": {
  166. "category": "functionality",
  167. "description": "禁止在分支条件判断中有赋值操作"
  168. },
  169. "no-console": {
  170. "category": "functionality",
  171. "description": "禁止使用 `console`",
  172. "reason": "没必要禁止,会让 autofixOnSave 很不方便"
  173. },
  174. "no-construct": {
  175. "category": "functionality",
  176. "description": "禁止使用 `new` 来生成 `String`, `Number` 或 `Boolean`"
  177. },
  178. "no-debugger": {
  179. "category": "functionality",
  180. "description": "禁止使用 `debugger`",
  181. "reason": "没必要禁止,会让 autofixOnSave 很不方便"
  182. },
  183. "no-duplicate-super": {
  184. "category": "functionality",
  185. "description": "禁止 `super` 在一个构造函数中出现两次"
  186. },
  187. "no-duplicate-switch-case": {
  188. "category": "functionality",
  189. "description": "禁止在 `switch` 语句中出现重复测试表达式的 `case`"
  190. },
  191. "no-duplicate-variable": {
  192. "category": "functionality",
  193. "description": "禁止出现重复的变量定义或函数参数名"
  194. },
  195. "no-dynamic-delete": {
  196. "category": "functionality",
  197. "description": "禁止 `delete` 动态的值",
  198. "reason": "没必要限制"
  199. },
  200. "no-empty": {
  201. "category": "functionality",
  202. "description": "禁止出现空代码块,允许 `catch` 是空代码块"
  203. },
  204. "no-eval": { "category": "functionality", "description": "禁止使用 `eval`" },
  205. "no-floating-promises": {
  206. "category": "functionality",
  207. "description": "函数返回值为 `Promise` 时,必须被处理",
  208. "reason": "太严格了\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  209. "ts-only": true,
  210. "requires-type-info": true
  211. },
  212. "no-for-in-array": {
  213. "category": "functionality",
  214. "description": "禁止对 `array` 使用 `for in` 循环",
  215. "reason": "没必要限制\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  216. "requires-type-info": true
  217. },
  218. "no-implicit-dependencies": {
  219. "category": "functionality",
  220. "description": "禁止引入 `package.json` 中不存在的模块"
  221. },
  222. "no-inferred-empty-object-type": {
  223. "category": "functionality",
  224. "description": "禁止推论出的类型是空对象类型",
  225. "reason": "没必要限制\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  226. "ts-only": true,
  227. "requires-type-info": true
  228. },
  229. "no-invalid-template-strings": {
  230. "category": "functionality",
  231. "description": "禁止在非模版字符串中出现 `${}`"
  232. },
  233. "no-invalid-this": {
  234. "category": "functionality",
  235. "description": "禁止在类外面使用 `this`",
  236. "reason": "禁止滥用 `this`,如需使用,在文件中局部禁用此规则即可"
  237. },
  238. "no-misused-new": {
  239. "category": "functionality",
  240. "description": "禁止在接口中定义 `constructor`,或在类中定义 `new`",
  241. "ts-only": true
  242. },
  243. "no-null-keyword": {
  244. "category": "functionality",
  245. "description": "禁止使用 `null`",
  246. "reason": "没必要限制",
  247. "has-fixer": true
  248. },
  249. "no-object-literal-type-assertion": {
  250. "category": "functionality",
  251. "description": "禁止对对象字面量进行类型断言(断言成 `any` 是允许的)",
  252. "ts-only": true
  253. },
  254. "no-return-await": {
  255. "category": "functionality",
  256. "description": "禁止没必要的 `return await`",
  257. "reason": "`return await` 用起来没问题",
  258. "has-fixer": true
  259. },
  260. "no-shadowed-variable": {
  261. "category": "functionality",
  262. "description": "禁止变量名与上层作用域内的定义过的变量重复",
  263. "reason": "很多时候函数的形参和传参是同名的"
  264. },
  265. "no-sparse-arrays": {
  266. "category": "functionality",
  267. "description": "禁止在数组中出现连续的逗号,如 `let foo = [,,]`"
  268. },
  269. "no-string-literal": {
  270. "category": "functionality",
  271. "description": "禁止出现 `foo['bar']`,必须写成 `foo.bar`",
  272. "has-fixer": true
  273. },
  274. "no-string-throw": {
  275. "category": "functionality",
  276. "description": "禁止 `throw` 字符串,必须 `throw` 一个 `Error` 对象",
  277. "has-fixer": true
  278. },
  279. "no-submodule-imports": {
  280. "category": "functionality",
  281. "description": "禁止 `import` 模块的子文件",
  282. "reason": "没必要限制"
  283. },
  284. "no-switch-case-fall-through": {
  285. "category": "functionality",
  286. "description": "`switch` 的 `case` 必须 `return` 或 `break`"
  287. },
  288. "no-this-assignment": {
  289. "category": "functionality",
  290. "description": "禁止将 `this` 赋值给其他变量,除非是解构赋值"
  291. },
  292. "no-unbound-method": {
  293. "category": "functionality",
  294. "description": "使用实例的方法时,必须 `bind` 到实例上",
  295. "reason": "Requires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  296. "ts-only": true,
  297. "requires-type-info": true
  298. },
  299. "no-unnecessary-class": {
  300. "category": "functionality",
  301. "description": "禁止定义没必要的类,比如只有静态方法的类",
  302. "reason": "没必要限制"
  303. },
  304. "no-unsafe-any": {
  305. "category": "functionality",
  306. "description": "禁止取用一个类型为 `any` 的对象的属性",
  307. "reason": "太严格了\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  308. "ts-only": true,
  309. "requires-type-info": true
  310. },
  311. "no-unsafe-finally": {
  312. "category": "functionality",
  313. "description": "禁止 `finally` 内出现 `return`, `continue`, `break`, `throw` 等",
  314. "reason": "`finally` 会比 `catch` 先执行"
  315. },
  316. "no-unused-expression": { "category": "functionality", "description": "禁止无用的表达式" },
  317. "no-use-before-declare": {
  318. "category": "functionality",
  319. "description": "变量必须先定义后使用",
  320. "reason": "循环引用没法处理\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  321. "requires-type-info": true
  322. },
  323. "no-var-keyword": {
  324. "category": "functionality",
  325. "description": "禁止使用 `var`",
  326. "has-fixer": true
  327. },
  328. "no-void-expression": {
  329. "category": "functionality",
  330. "description": "禁止返回值为 `void` 类型",
  331. "reason": "没必要限制,`void` 很常用\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  332. "requires-type-info": true
  333. },
  334. "prefer-conditional-expression": {
  335. "category": "functionality",
  336. "description": "可以用三元表达式时,就不用 `if else`",
  337. "reason": "没必要限制"
  338. },
  339. "prefer-object-spread": {
  340. "category": "functionality",
  341. "description": "使用 `{ ...foo, bar: 1 }` 代替 `Object.assign({}, foo, { bar: 1 })`",
  342. "reason": "前者的类型检查更完善",
  343. "has-fixer": true
  344. },
  345. "radix": { "category": "functionality", "description": "`parseInt` 必须传入第二个参数" },
  346. "restrict-plus-operands": {
  347. "category": "functionality",
  348. "description": "使用加号时,两者必须同为数字或同为字符串",
  349. "reason": "太严格了\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  350. "requires-type-info": true
  351. },
  352. "strict-boolean-expressions": {
  353. "category": "functionality",
  354. "description": "在分支条件判断中必须传入布尔类型的值",
  355. "reason": "太严格了\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  356. "ts-only": true,
  357. "requires-type-info": true
  358. },
  359. "strict-type-predicates": {
  360. "category": "functionality",
  361. "description": "禁止出现永远为 `true` 或永远为 `false` 的条件判断(通过类型预测出一个表达式为 `true` 还是 `false`)",
  362. "reason": "没必要限制\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  363. "ts-only": true,
  364. "requires-type-info": true
  365. },
  366. "switch-default": {
  367. "category": "functionality",
  368. "description": "`switch` 语句必须有 `default`"
  369. },
  370. "triple-equals": {
  371. "category": "functionality",
  372. "description": "必须使用 `===` 或 `!==`,禁止使用 `==` 或 `!=`"
  373. },
  374. "typeof-compare": {
  375. "category": "functionality",
  376. "description": "`typeof` 表达式比较的对象必须是 `'undefined'`, `'object'`, `'boolean'`, `'number'`, `'string'`, `'function'` 或 `'symbol'`",
  377. "reason": "TypeScirpt 2.2 之后,编译器已经只带了这个功能"
  378. },
  379. "use-default-type-parameter": {
  380. "category": "functionality",
  381. "description": "传入的类型与默认类型一致时,必须省略传入的类型",
  382. "reason": "没必要限制\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  383. "ts-only": true,
  384. "requires-type-info": true
  385. },
  386. "use-isnan": {
  387. "category": "functionality",
  388. "description": "必须使用 `isNaN(foo)` 而不是 `foo === NaN`"
  389. },
  390. "cyclomatic-complexity": {
  391. "category": "maintainability",
  392. "description": "禁止函数的循环复杂度超过 20,详见 https://en.wikipedia.org/wiki/Cyclomatic_complexity"
  393. },
  394. "deprecation": {
  395. "category": "maintainability",
  396. "description": "禁止使用废弃(被标识了 `@deprecated`)的 API",
  397. "reason": "太严格了\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  398. "requires-type-info": true
  399. },
  400. "eofline": {
  401. "category": "maintainability",
  402. "description": "文件最后一行必须有一个空行",
  403. "has-fixer": true,
  404. "prettier": true
  405. },
  406. "indent": {
  407. "category": "maintainability",
  408. "description": "一个缩进必须用四个空格替代",
  409. "has-fixer": true,
  410. "prettier": true
  411. },
  412. "linebreak-style": {
  413. "category": "maintainability",
  414. "description": "限制换行符为 LF 或 CRLF",
  415. "reason": "没必要限制",
  416. "has-fixer": true,
  417. "prettier": true
  418. },
  419. "max-classes-per-file": {
  420. "category": "maintainability",
  421. "description": "限制每个文件的类的数量",
  422. "reason": "没必要限制"
  423. },
  424. "max-file-line-count": {
  425. "category": "maintainability",
  426. "description": "限制每个文件的行数",
  427. "reason": "没必要限制"
  428. },
  429. "max-line-length": {
  430. "category": "maintainability",
  431. "description": "限制每行字符数",
  432. "reason": "没必要限制",
  433. "prettier": true
  434. },
  435. "no-default-export": {
  436. "category": "maintainability",
  437. "description": "禁止使用 `default export`",
  438. "reason": "没必要限制"
  439. },
  440. "no-duplicate-imports": {
  441. "category": "maintainability",
  442. "description": "禁止出现重复的 `import`"
  443. },
  444. "no-mergeable-namespace": {
  445. "category": "maintainability",
  446. "description": "禁止一个文件中出现多个相同的 `namespace`",
  447. "ts-only": true
  448. },
  449. "no-require-imports": {
  450. "category": "maintainability",
  451. "description": "禁止使用 `require`",
  452. "reason": "有时需要动态引入,还是需要用 `require`"
  453. },
  454. "object-literal-sort-keys": {
  455. "category": "maintainability",
  456. "description": "对象字面量必须按 `key` 排序",
  457. "reason": "太严格了"
  458. },
  459. "prefer-const": {
  460. "category": "maintainability",
  461. "description": "申明后不再被修改的变量必须使用 `const` 来申明",
  462. "reason": "没必要强制要求",
  463. "has-fixer": true
  464. },
  465. "prefer-readonly": {
  466. "category": "maintainability",
  467. "description": "如果私有变量只在构造函数中被赋值,则必须使用 `readonly` 修饰符",
  468. "reason": "没必要限制\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  469. "ts-only": true,
  470. "requires-type-info": true
  471. },
  472. "trailing-comma": {
  473. "category": "maintainability",
  474. "description": "限制对象、数组、解构赋值等的最后一项末尾是否需要逗号",
  475. "has-fixer": true,
  476. "prettier": true
  477. },
  478. "align": {
  479. "category": "style",
  480. "description": "变量定义需要竖向对其",
  481. "reason": "没必要限制",
  482. "has-fixer": true,
  483. "prettier": true
  484. },
  485. "array-type": {
  486. "category": "style",
  487. "description": "限制必须使用 `T[]` 或 `Array<T>` 之中的一种来定义数组的类型",
  488. "reason": "没必要限制",
  489. "ts-only": true,
  490. "has-fixer": true
  491. },
  492. "arrow-parens": {
  493. "category": "style",
  494. "description": "箭头函数的参数必须有小括号",
  495. "has-fixer": true,
  496. "prettier": true
  497. },
  498. "arrow-return-shorthand": {
  499. "category": "style",
  500. "description": "箭头函数的函数体只有 `return` 语句的时候,必须简写",
  501. "has-fixer": true
  502. },
  503. "binary-expression-operand-order": {
  504. "category": "style",
  505. "description": "数字字面量必须在加号的右边,即禁止 `1 + x`",
  506. "reason": "没必要限制"
  507. },
  508. "callable-types": {
  509. "category": "style",
  510. "description": "可以简写为函数类型的接口或字面类似,必须简写",
  511. "ts-only": true,
  512. "has-fixer": true
  513. },
  514. "class-name": { "category": "style", "description": "类名与接口名必须为驼峰式" },
  515. "comment-format": {
  516. "category": "style",
  517. "description": "限制单行注释的规则",
  518. "has-fixer": true
  519. },
  520. "completed-docs": {
  521. "category": "style",
  522. "description": "类、函数等必须写注释",
  523. "reason": "太严格了\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  524. "requires-type-info": true
  525. },
  526. "encoding": { "category": "style", "description": "文件类型必须是 utf-8" },
  527. "file-header": {
  528. "category": "style",
  529. "description": "文件的开头必须有指定的字符串",
  530. "reason": "太严格了",
  531. "has-fixer": true
  532. },
  533. "file-name-casing": {
  534. "category": "style",
  535. "description": "约束文件命名规范",
  536. "reason": "没必要约束"
  537. },
  538. "import-spacing": {
  539. "category": "style",
  540. "description": "`import` 语句中,关键字之间的间距必须是一个空格",
  541. "prettier": true
  542. },
  543. "interface-name": {
  544. "category": "style",
  545. "description": "接口名称必须已 `I` 开头",
  546. "reason": "没必要限制",
  547. "ts-only": true
  548. },
  549. "interface-over-type-literal": {
  550. "category": "style",
  551. "description": "优先使用接口而不是字面类型",
  552. "reason": "接口可以 `implement` `extend` 和 `merge`",
  553. "ts-only": true,
  554. "has-fixer": true
  555. },
  556. "jsdoc-format": { "category": "style", "description": "注释必须符合 JSDoc 规范" },
  557. "match-default-export-name": {
  558. "category": "style",
  559. "description": "`import` 的名称必须和 `export default` 的名称一致",
  560. "reason": "没必要限制\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  561. "ts-only": true,
  562. "requires-type-info": true
  563. },
  564. "new-parens": {
  565. "category": "style",
  566. "description": "`new` 后面只必须有一个空格",
  567. "prettier": true
  568. },
  569. "newline-before-return": {
  570. "category": "style",
  571. "description": "`return` 语句前必须有空行",
  572. "reason": "没必要有空行"
  573. },
  574. "newline-per-chained-call": {
  575. "category": "style",
  576. "description": "链式调用时,每次调用都必须占用一行",
  577. "reason": "没必要限制",
  578. "prettier": true
  579. },
  580. "no-angle-bracket-type-assertion": {
  581. "category": "style",
  582. "description": "类型断言必须使用 `as Type`,禁止使用 `<Type>`",
  583. "reason": "`<Type>` 容易被理解为 jsx",
  584. "ts-only": true,
  585. "has-fixer": true
  586. },
  587. "no-boolean-literal-compare": {
  588. "category": "style",
  589. "description": "禁止变量与 `true` 或 `false` 比较",
  590. "reason": "没必要限制\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  591. "ts-only": true,
  592. "has-fixer": true,
  593. "requires-type-info": true
  594. },
  595. "no-consecutive-blank-lines": {
  596. "category": "style",
  597. "description": "禁止连续超过三行空行",
  598. "has-fixer": true,
  599. "prettier": true
  600. },
  601. "no-irregular-whitespace": {
  602. "category": "style",
  603. "description": "禁止使用特殊空白符(比如全角空格)",
  604. "has-fixer": true,
  605. "prettier": true
  606. },
  607. "no-parameter-properties": {
  608. "category": "style",
  609. "description": "禁止给类的构造函数的参数添加修饰符",
  610. "ts-only": true
  611. },
  612. "no-redundant-jsdoc": {
  613. "category": "style",
  614. "description": "禁止 JSDoc 中的冗余类型声明,因为 TypeScirpt 已经包含了大部分功能",
  615. "ts-only": true
  616. },
  617. "no-reference-import": {
  618. "category": "style",
  619. "description": "如果已经引入过库,则禁止使用三斜杠引入类型定义文件",
  620. "ts-only": true
  621. },
  622. "no-trailing-whitespace": {
  623. "category": "style",
  624. "description": "禁止行尾有空格",
  625. "has-fixer": true,
  626. "prettier": true
  627. },
  628. "no-unnecessary-callback-wrapper": {
  629. "category": "style",
  630. "description": "禁止没必要的函数调用,如 `x => f(x)` 应该简写为 `f`",
  631. "reason": "没必要限制"
  632. },
  633. "no-unnecessary-initializer": {
  634. "category": "style",
  635. "description": "禁止变量定义时赋值为 `undefined`",
  636. "has-fixer": true
  637. },
  638. "no-unnecessary-qualifier": {
  639. "category": "style",
  640. "description": "在命名空间中,可以直接使用内部变量,不需要添加命名空间前缀",
  641. "reason": "已经禁止使用命名空间了\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  642. "ts-only": true,
  643. "has-fixer": true,
  644. "requires-type-info": true
  645. },
  646. "number-literal-format": {
  647. "category": "style",
  648. "description": "小数必须以 `0.` 开头,禁止以 `.` 开头,并且不能以 `0` 结尾",
  649. "prettier": true
  650. },
  651. "object-literal-key-quotes": {
  652. "category": "style",
  653. "description": "对象的 key 必须用引号包起来",
  654. "reason": "没必要限制",
  655. "has-fixer": true,
  656. "prettier": true
  657. },
  658. "object-literal-shorthand": {
  659. "category": "style",
  660. "description": "必须使用 `a = {b}` 而不是 `a = {b: b}`",
  661. "has-fixer": true
  662. },
  663. "one-line": {
  664. "category": "style",
  665. "description": "`if` 后的 `{` 禁止换行",
  666. "has-fixer": true,
  667. "prettier": true
  668. },
  669. "one-variable-per-declaration": {
  670. "category": "style",
  671. "description": "变量申明必须每行一个,`for` 循环的初始条件中除外"
  672. },
  673. "ordered-imports": {
  674. "category": "style",
  675. "description": "`import` 必须排序",
  676. "has-fixer": true
  677. },
  678. "prefer-function-over-method": {
  679. "category": "style",
  680. "description": "类中没有使用 `this` 的方法应该提取成类外的函数",
  681. "reason": "太严格了"
  682. },
  683. "prefer-method-signature": {
  684. "category": "style",
  685. "description": "必须使用 `foo(): void` 而不是 `foo: () => void`",
  686. "reason": "没必要限制",
  687. "has-fixer": true
  688. },
  689. "prefer-switch": {
  690. "category": "style",
  691. "description": "当 `if` 中只有 `===` 时,必须使用 `switch` 替换 `if`",
  692. "reason": "没必要限制"
  693. },
  694. "prefer-template": {
  695. "category": "style",
  696. "description": "必须使用模版字符串而不是字符串连接",
  697. "reason": "字符串连接很常用"
  698. },
  699. "prefer-while": {
  700. "category": "style",
  701. "description": "当没有初始值的时候,必须使用 `while` 而不是 `for`",
  702. "reason": "没必要限制",
  703. "has-fixer": true
  704. },
  705. "quotemark": {
  706. "category": "style",
  707. "description": "必须使用单引号,jsx 中必须使用双引号",
  708. "has-fixer": true,
  709. "prettier": true
  710. },
  711. "return-undefined": {
  712. "category": "style",
  713. "description": "使用 `return;` 而不是 `return undefined;`",
  714. "reason": "没必要限制\nRequires Type Info 的规则,无法在编辑器中显示错误,不方便修复",
  715. "requires-type-info": true
  716. },
  717. "semicolon": {
  718. "category": "style",
  719. "description": "行尾必须有分号",
  720. "has-fixer": true,
  721. "prettier": true
  722. },
  723. "space-before-function-paren": {
  724. "category": "style",
  725. "description": "函数名前必须有空格",
  726. "has-fixer": true,
  727. "prettier": true
  728. },
  729. "space-within-parens": {
  730. "category": "style",
  731. "description": "括号内首尾禁止有空格",
  732. "has-fixer": true,
  733. "prettier": true
  734. },
  735. "switch-final-break": {
  736. "category": "style",
  737. "description": "`switch` 的最后一项禁止有 `break`",
  738. "reason": "没必要限制",
  739. "has-fixer": true
  740. },
  741. "type-literal-delimiter": {
  742. "category": "style",
  743. "description": "字面类型的每个成员都必须有分号",
  744. "ts-only": true
  745. },
  746. "variable-name": {
  747. "category": "style",
  748. "description": "限制变量命名规则",
  749. "reason": "没必要限制"
  750. },
  751. "whitespace": {
  752. "category": "style",
  753. "description": "限制空格的位置",
  754. "has-fixer": true,
  755. "prettier": true
  756. }
  757. }