no-mixed-spaces-and-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
.
大多数代码约定要求使用制表符或空格进行缩进。因此,如果一行代码同时使用制表符和空格缩进,通常是错误的。
¥Most code conventions require either tabs or spaces be used for indentation. As such, it’s usually an error if a single line of code is indented with both tabs and spaces.
规则详情
¥Rule Details
此规则不允许使用混合空格和制表符进行缩进。
¥This rule disallows mixed spaces and tabs for indentation.
此规则的错误代码示例:
¥Examples of incorrect code for this rule:
/*eslint no-mixed-spaces-and-tabs: "error"*/
function add(x, y) {
return x + y;
}
function main() {
var x = 5,
y = 7;
}
此规则的正确代码示例:
¥Examples of correct code for this rule:
/*eslint no-mixed-spaces-and-tabs: "error"*/
function add(x, y) {
return x + y;
}
选项
¥Options
此规则有一个字符串选项。
¥This rule has a string option.
-
当使用空格进行对齐时,
"smart-tabs"
允许混合制表符和空格。¥
"smart-tabs"
allows mixed tabs and spaces when the spaces are used for alignment.
smart-tabs
使用 "smart-tabs"
选项的此规则的正确代码示例:
¥Examples of correct code for this rule with the "smart-tabs"
option:
/*eslint no-mixed-spaces-and-tabs: ["error", "smart-tabs"]*/
function main() {
var x = 5,
y = 7;
}
版本
此规则是在 ESLint v0.7.1 中引入。