prettier / eslint-config-prettier

Turns off all rules that are unnecessary or might conflict with Prettier.
MIT License
5.41k stars 254 forks source link

4 space tab rule conflicts with long a ? b : c statements #54

Closed jlchereau closed 5 years ago

jlchereau commented 5 years ago

For example image but with 28 spaces: image

Environment

Full configuration:

{
    "env": {
        "node": true,
        "es6": true
    },
    "extends": [
        "airbnb-base",
        "plugin:node/recommended",
        "prettier"
    ],
    "parser": "esprima",
    "plugins": [
        "node",
        "prettier"
    ],
    "root": true,
    "rules": {
        "indent": ["error", 4, { "SwitchCase": 1 }],
        "no-plusplus": ["error", { "allowForLoopAfterthoughts": true }],
        "no-underscore-dangle": 0,
        "node/exports-style": ["error", "module.exports"],
        "prettier/prettier": ["error", {
            "singleQuote": true,
            "tabWidth": 4
        }]
    }
}

And for .prettierrc

{
    "singleQuote": true,
    "tabWidth": 4
}

*Source code causing the issue.**

Any code that has a long a ? b : c statement will trigger the conflict:

            new PageComponent({
                tool: 'textbox',
                top: 380,
                left: 80,
                width: 380,
                height: 100,
                properties: {
                    question: options.question,
                    solution: solutions[0],
                    validation:
                        solutions.length > 1
                            ? `// ignoreCaseMatch ${JSON.stringify([
                                `^(?:${escaped.join('|')})$`
                            ])}`
                            : '// ignoreCaseEqual'
                }
            })

This runs In WebStorm with the following config:

image

But also using grunt-eslint configured in grunfile.js as follows:

        eslint: {
            files: [
                '*.js',
                'templates/*.es6',
                'src/js/**/*.es6',
                'test/**/*.es6'
            ],
            options: {
                config: '.eslintrc'
            }
        },
lydell commented 5 years ago

Remove this line from your ESLint config:

"indent": ["error", 4, { "SwitchCase": 1 }],