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

feat: make class prop decorators inline

Open stagas opened this issue 2 years ago • 3 comments

Changes this:

@$.element()
class Foo extends HTMLElement {
  @$.attr()
  color = 'blue'
  @$.attr()
  another = 123
  @$.attr()
  withCapital = true

  button?: HTMLButtonElement
  result?: number = 123

to this:

@$.element()
class Foo extends HTMLElement {
  @$.attr() color = 'blue'
  @$.attr() another = 123
  @$.attr() withCapital = true

  button?: HTMLButtonElement
  result?: number = 123

The tests pass however I'm not 100% confident that it won't produce invalid code in some combination of modifiers or other occassions. We need probably more tests? Should I try and add them?

stagas avatar Jun 25 '22 13:06 stagas

Thanks, but I don't think we should do this since prettier doesn't do it. Instead I think we should copy prettier's behaviour and leave decorators on the same line that they appeared or revert back to the previous line if the property is long: https://prettier.io/playground/#N4Igxg9gdgLgprEAuEABAJAOjgGzgWwRgAoBKAHSjBwEMBnOgAgDEIJG4APeKAEyYASAFQCyAGQCieQrEbBKjRhkw0YMAE5kFjSDgjrGAXkYByAEY4ArnBPblqjWUY0oEGAAs46oXF9--AYFBwSHBdDBGjACMAEwAzHZYDpqkzq4eXpGxCVCK9mop2gDuAJYeAMI0AA5lNDiRGtaU2maWatAA-EiMwuIAQm0w0FIERNrqcHSWODBdjFCW+GaZxtmUAL4gADQgEFUwJdB0yKA06uoQRQAKZwjHKHVFNACexztm6jRgANZwMADKNEIYhKUDgyAAZnU6HB3p8fn9-lUvqCAObIRqwkAEZa8XhwXhiFyoyw0VFwVjqfAONHIEA0NoQbYgdwwfA4ADq7jKk2RYDg-zuZRKADcys86WAGMzQTD1DArp9UdTIdCsQArOicf5ovAARUsbnBSChOBhO2R6jldJgzyqkzA6hK+2ZVSdsA5JV4HmQAA4AAwWi4wjmfKp0t2TLwi8E7ACOhvgir293pdAAtGCCQTmRMEyUJoqySqTWqdjD8CUMeprOXdXADUbVWasTAaGZPd73MgYjsNDQSjg0eUIPgS9i6ABWZmWGFCdv3U3mkAi6wAST4RH+judMAAgnx-ra8M2Yet1kA

dsherret avatar Jun 26 '22 16:06 dsherret

Yes that would be ideal. Any ideas how to go about it?

stagas avatar Jun 26 '22 16:06 stagas

Can this be enabled optionally via config in the meantime? This feature is essential for following Angular style guidelines

alphatwit avatar Dec 11 '23 20:12 alphatwit