How to cofigure tslint or prettier to remove whitespace between if/while/for and ()?

Viewed 4124

I'm setting up react project and format my code with tslint, prettier and tslint-config-prettier. Also autoFormat with vscode.

How can I remove space between if/while/for and parenthese like 'if()' not 'if ()'?

I couldn't find the option related with this in tslint and prettier. But I found 'keyword-spacing' in eslint. So I expect tslint and prettier to inclue something like keyword-spacing.

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 (in vscode for reference)

{
    "editor.formatOnSave": true,
    "tslint.enable": true,
    "tslint.jsEnable": true,
    "tslint.alwaysShowRuleFailuresAsWarnings": true,
    "tslint.alwaysShowStatus": true,
    "tslint.autoFixOnSave": true
}

expected:

let i: number = 0;
if(i <= 10) {
    i++;
}

actual:

let i: number = 0;
if (i <= 10) {
    i++;
}

Thanks a lot in advance!

0 Answers
Related