no-mixed-spaces-and-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.
大多数代码约定要求缩进使用制表符或空格。因此,如果一行代码同时使用制表符和空格进行缩进,通常就是错误的。
🌐 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
使用 "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 中引入。