no-mixed-spaces-and-tabs
不允許混合使用空格和 Tab 進行縮排
大多數程式碼慣例要求使用 Tab 或空格進行縮排。因此,如果單行程式碼同時使用 Tab 和空格進行縮排,通常會被視為錯誤。
規則詳細資訊
此規則不允許混合使用空格和 Tab 進行縮排。
此規則的 錯誤 程式碼範例
在 Playground 中開啟
/*eslint no-mixed-spaces-and-tabs: "error"*/
function add(x, y) {
return x + y;
}
function main() {
var x = 5,
y = 7;
}
此規則的 正確 程式碼範例
在 Playground 中開啟
/*eslint no-mixed-spaces-and-tabs: "error"*/
function add(x, y) {
return x + y;
}
選項
此規則有一個字串選項。
"smart-tabs"
允許混合使用 Tab 和空格,當空格用於對齊時。
smart-tabs
此規則搭配 "smart-tabs"
選項的 正確 程式碼範例
在 Playground 中開啟
/*eslint no-mixed-spaces-and-tabs: ["error", "smart-tabs"]*/
function main() {
var x = 5,
y = 7;
}
版本
此規則在 ESLint v0.7.1 中引入。