RobinMalfait / prettier-eslint-code

[DEPRECATED] A vscode extension to format javascript using prettier-eslint
24 stars 7 forks source link

Formatting incorrect for extension but not for the native `prettier-eslint` package! #27

Closed wbern closed 7 years ago

wbern commented 7 years ago

Originally reported in prettier-eslint repo: https://github.com/prettier/prettier-eslint/issues/100#issuecomment-312273440

prettier-eslint-cli creates this:

        if (
            !renderUnconditionally &&
            this &&
            (!this.caller ||
                this.caller === this ||
                !this.internalVirtualNode ||
                this.caller === this.internalVirtualNode.componentInstance)
        ) {
            renderUnconditionally = true;
        }

Then running prettier-eslint vscode extension turns it into this:

        if (
            !renderUnconditionally &&
      this &&
      (!this.caller ||
        this.caller === this ||
        !this.internalVirtualNode ||
        this.caller === this.internalVirtualNode.componentInstance)
        ) {
            renderUnconditionally = true;
        }

Not sure what is causing this, but it leaves the extension broken (for me) right now.

Update: I suspect the following is creating issues:

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

If I change spaces from 4 to 2, I get correct output. Also removing the .eslintrc file completely gives me 2 spaces and correct output.

    if (
      !renderUnconditionally &&
      this &&
      (!this.caller ||
        this.caller === this ||
        !this.internalVirtualNode ||
        this.caller === this.internalVirtualNode.componentInstance)
    ) {
      renderUnconditionally = true;
    }
wbern commented 7 years ago

Using https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode instead, as this package is being deprecated, and it works!