no-tabs
禁止所有标签
This rule was deprecated in ESLint v8.53.0. It will be removed in v11.0.0. Please use the corresponding rule in @stylistic/eslint-plugin.
一些风格指南根本不允许使用制表符,包括在注释中。
🌐 Some style guides don’t allow the use of tab characters at all, including within comments.
规则详情
🌐 Rule Details
此规则会检查文件中任何地方的制表符:代码、注释或其他任何内容。
🌐 This rule looks for tabs anywhere inside a file: code, comments or anything else.
此规则的错误代码示例:
🌐 Examples of incorrect code for this rule:
::: 错误
/* eslint no-tabs: "error" */
var a = 2;
/**
* it's a test function
*/
function test(){}
var x = 1; // test
:::
符合此规则的正确代码示例:
🌐 Examples of correct code for this rule:
/* eslint no-tabs: "error" */
var a = 2;
/**
* it's a test function
*/
function test(){}
var x = 1; // test
选项
🌐 Options
此规则有一个可选对象选项,具有以下属性:
🌐 This rule has an optional object option with the following properties:
allowIndentationTabs(默认值:false):如果设置为 true,则规则不会报告用于缩进的制表符。
allowIndentationTabs
使用 allowIndentationTabs: true 选项时,此规则的正确代码示例:
🌐 Examples of correct code for this rule with the allowIndentationTabs: true option:
::: 正确
/* eslint no-tabs: ["error", { allowIndentationTabs: true }] */
function test() {
doSomething();
}
// comment with leading indentation tab
:::
何时不使用
🌐 When Not To Use It
如果你已经建立了可以使用标签的标准,那么你可以禁用此规则。
🌐 If you have established a standard where having tabs is fine, then you can disable this rule.
兼容性
🌐 Compatibility
- JSCS: disallowTabs
版本
此规则是在 ESLint v3.2.0 中引入。