dprint-plugin-typescript icon indicating copy to clipboard operation
dprint-plugin-typescript copied to clipboard

Handle block scoped alignement formatting

Open axetroy opened this issue 4 years ago • 1 comments

Before:

const bike: Record<string|number> = {
    wheelSize: 16,
    topTubeLength: 24.5,
    manufacturer: 'Brompton'
};

After:

const bike: Record<string|number> = {
    wheelSize.   : 16,
    topTubeLength: 24.5,
    manufacturer : 'Brompton'
};

I think the attribute should be more readable for it

consider adding an option to support it

Proposal

  • Align property/value of the object
const man = {
  name.  : "nick",
  age    : 18,
  address: "your address"
}
  • Align variable declaration
var name 	= "nick"
var age 	= 18
var address = "your address"
  • Align comment of lines
const name    = 'tony' // comment 1
var   address = 'lsg'  // comment 2
let   age.    = 18     // comment 3
  • Align interface declaration for Typescript
interface People {
  name.  : string // comment 1
  age.   : number // comment 2
  address: string // comment 3
}

axetroy avatar Jun 21 '20 06:06 axetroy

It would be cool, but in order to be efficient and to do this, it would require some new functionality in the core library. It probably won't happen for a while since it's such a large task.

dsherret avatar Jun 27 '20 17:06 dsherret