ban-tslint-comment
禁止
// tslint:<rule-flag>
註解。
🎨
擴充 "plugin:@typescript-eslint/stylistic"
中的 ESLint 配置 啟用這個規則。
🔧
這個規則所報告的某些問題可以自動修正,利用 ESLint 命令列選項 --fix
.
從 TSLint 轉移至 ESLint 時會很有用。在移除 TSLint 之後,這條規則會協助找出 TSLint 註解 (例如 // tslint:disable
)。
請參閱 TSLint 規則標記文件 以供參考。
.eslintrc.cjs
module.exports = {
"rules": {
"@typescript-eslint/ban-tslint-comment": "error"
}
};
在遊樂場中嘗試這條規則 ↗
範例
- ❌ 錯誤
- ✅ 正確
/* 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...
在遊樂場中開啟// 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
在遊樂場中開啟選項
此規則不能設定。
什麼時候不使用這條規則
如果在 ESLint 旁邊還在使用 TSLint。