ban-ts-comment
NOTE: this rule is part of the
推荐
rule set.Enable full set in
deno.json
:{ "lint": { "rules": { "tags": ["推荐"] } } }
Enable full set using the Deno CLI:
deno lint --rules-tags=推荐
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the
include
or exclude
array in deno.json
:{ "lint": { "rules": { "include": ["ban-ts-comment"], "exclude": ["ban-ts-comment"] } } }
不允许在没有注释的情况下使用 Typescript 指令。
Typescript 指令降低了编译器的有效性,这种情况应仅在特殊情况下使用。原因应在指令旁边通过注释进行说明。
无效:
// @ts-expect-error
let a: number = "I am a string";
// @ts-ignore
let a: number = "I am a string";
// @ts-nocheck
let a: number = "I am a string";
有效:
// @ts-expect-error: 临时解决方案(请参见票据 #422)
let a: number = "I am a string";
// @ts-ignore: 临时解决方案(请参见票据 #422)
let a: number = "I am a string";
// @ts-nocheck: 临时解决方案(请参见票据 #422)
let a: number = "I am a string";