我正在设置react项目并使用tslint,prettier和tslint-config-prettier格式化我的代码。还可以使用vscode自动格式化。
如何删除if / while / for和'if()'而非'if()'等括号之间的空格?
我在tslint和漂亮的中找不到与此相关的选项。但是我在埃斯林特发现了'keyword-spacing'。因此,我希望tslint和更漂亮的内容能够包含诸如关键字间距之类的内容。
tslint.json
{
"extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
"linterOptions": {
"exclude": [
"config/**/*.js",
"node_modules/**/*.ts",
"coverage/lcov-report/*.js"
]
},
"rules": {
"class-name": true,
"comment-format": [true, "check-space"],
"curly": true,
"interface-name": false,
"interface-over-type-literal": false,
"jsx-boolean-value": false,
"no-console": false,
"no-duplicate-variable": true,
"no-empty-interface": true,
"no-internal-module": true,
"no-var-keyword": true,
"object-literal-sort-keys": false,
"ordered-imports": false
}
}
.prettierrc
{
"trailingComma": "es5",
"tabWidth": 4,
"semi": true,
"singleQuote": true,
"bracketSpacing": true,
"quotes": true,
"jsxSingleQuote": false
}
settings.json(在vscode中供参考)
{
"editor.formatOnSave": true,
"tslint.enable": true,
"tslint.jsEnable": true,
"tslint.alwaysShowRuleFailuresAsWarnings": true,
"tslint.alwaysShowStatus": true,
"tslint.autoFixOnSave": true
}
预期:
let i: number = 0;
if(i <= 10) {
i++;
}
实际:
let i: number = 0;
if (i <= 10) {
i++;
}
非常感谢!