coderaiser / putout

🐊 Pluggable and configurable JavaScript Linter, code transformer and formatter, drop-in ESLint superpower replacement 💪 with built-in support for js, jsx, typescript, flow, markdown, yaml and json. Write declarative codemods in a simplest possible way 😏
https://putout.cloudcmd.io/
MIT License
705 stars 40 forks source link

putout formatter completely breaks static classes #159

Closed ElPrudi closed 1 year ago

ElPrudi commented 1 year ago

I really, really dislike that the putout formatter runs automatically when you want to fix a simple rule with this plugin. One of the worst offenders is, that it turns this:

abstract class X {
    static #x?: boolean = true
    private static z: number = 5

    public static a(): boolean {
       this.#x = true
       const y = true
       return this.#x ? y : false
   }
}

to this:

abstract class X {
    #x: boolean = true 
    z: number = 5

    a() {
       this.#x = true
       const y = true
       return this.#x && y
   }
}

Just because it found this:

Simplify ternary (simplify-ternary/value)                               putout/putout

So it:

So, please give us an option to turn off the putout formatter. It's way too destructive.

coderaiser commented 1 year ago

Thank you! Just fixed in @putout/printer@2.85 🎉 . Please re-install 🐊.

Is it works for you?

You feedback really helps, anyways you can always switch to recast with:

{
    "printer": "recast"
}

It works slower than @putout/printer and has pure maintenance, but it more mature for now , anyways @putout/printer is much easier to support, and all regular JavaScript/JSX/TypeScript cases are supported (or will be when I have code examples 😏).

ElPrudi commented 1 year ago

Yes, setting it to recast fixed everything. Thank you very much :)