跳至主要內容

區塊前間距

已過時

格式化規則現已存在於 eslint-stylistic 中。 @stylistic/ts/space-before-blocks 是此規則的替代方案。
有關更多資訊,請參閱 已過時的格式化規則

強制在區塊前使用一致的間距。

🔧

此規則報告的一些問題可由下列自動修正: --fix ESLint 命令列選項.

此規則擴充了基礎 eslint/space-before-blocks 規則。它新增了對介面和列舉的支持。

enum Breakpoint{
Large,
Medium,
}

interface State{
currentBreakpoint: Breakpoint;
}
開啟遊樂場

如何使用

.eslintrc.cjs
module.exports = {
"rules": {
// Note: you must disable the base rule as it can report incorrect errors
"space-before-blocks": "off",
"@typescript-eslint/space-before-blocks": "error"
}
};

在遊樂場中嘗試這個規則 ↗

選項

請參閱 eslint/space-before-blocks 選項

萬一傳遞較具體的選項物件,區塊會遵循 classes 組態選項。

資源

出自 ESLint 核心,附上 ❤️。