简体   繁体   English

如何使用 eslint 在块(块前的空格)之前强制执行 1 个空格?

[英]How to enforce exactly 1 space before blocks (space-before-blocks) with eslint?

the problem in vscode: eslint ignores extra spaces when fixing: vscode中的问题:eslint在修复时忽略了额外的空格:

function() { - i need exactly 1 space here. function() { - 我这里正好需要 1 个空格。

the same happens with object notation: object 表示法也会发生同样的情况:

const test = { prop: true }; -> const test = {prop: true}; -> const test = {prop: true}; (doesnt work). (不起作用)。

either there're some other rules to force proper formatting or eslint is pretty limited at formatting.要么有一些其他规则来强制正确格式化,要么 eslint 在格式化方面非常有限。

on the other hand i dont like prettier since it destroys empty lines and js-beautify is limited in options also.另一方面,我不喜欢更漂亮,因为它会破坏空行,并且 js-beautify 的选项也有限。

any suggestions how to fix this problem?任何建议如何解决这个问题?

Add添加

'no-multi-spaces': ['error']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM