ban-tslint-comment
Disallow
// tslint:<rule-flag>
comments.
🎨
在 ESLint 配置 中扩展"plugin:@typescript-eslint/stylistic"
可启用此规则。
🔧
此规则报告的一些问题可通过 --fix
ESLint 命令行选项自动修复。
从 TSLint 迁移到 ESLint 时很有用。一旦 TSLint 被删除,此规则有助于定位 TSLint 注释(例如 // tslint:disable
)。
¥Useful when migrating from TSLint to ESLint. Once TSLint has been removed, this rule helps locate TSLint annotations (e.g. // tslint:disable
).
有关 参考,请参阅 TSLint 规则标志文档。
¥See the TSLint rule flags docs for reference.
- Flat Config
- Legacy Config
eslint.config.mjs
export default tseslint.config({
rules: {
"@typescript-eslint/ban-tslint-comment": "error"
}
});
.eslintrc.cjs
module.exports = {
"rules": {
"@typescript-eslint/ban-tslint-comment": "error"
}
};
在线运行试试这个规则 ↗
示例
¥Examples
- ❌ Incorrect
- ✅ Correct
/* tslint:disable */
/* tslint:enable */
/* tslint:disable:rule1 rule2 rule3... */
/* tslint:enable:rule1 rule2 rule3... */
// tslint:disable-next-line
someCode(); // tslint:disable-line
// tslint:disable-next-line:rule1 rule2 rule3...
Open in Playground// This is a comment that just happens to mention tslint
/* This is a multiline comment that just happens to mention tslint */
someCode(); // This is a comment that just happens to mention tslint
Open in Playground选项
该规则不可配置。
何时不使用它
¥When Not To Use It
如果你仍在将 TSLint 与 ESLint 一起使用。
¥If you are still using TSLint alongside ESLint.
'## 资源'