no-tabs
禁止所有标签
此规则在 ESLint v8.53.0 中已弃用。请在 @stylistic/eslint-plugin-js
中使用 相应的规则。
¥This rule was deprecated in ESLint v8.53.0. Please use the corresponding rule in @stylistic/eslint-plugin-js
.
一些风格指南根本不允许使用制表符,包括在注释中。
¥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
(默认值:假):如果设置为 true,则规则不会报告用于缩进的制表符。¥
allowIndentationTabs
(default: false): If this is set to true, then the rule will not report tabs used for indentation.
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 中引入。