lsdsjy / prettier-plugin-stylus

Prettier plugin for Stylus.
17 stars 2 forks source link

Line breaks being removed #4

Closed philefstat closed 2 years ago

philefstat commented 2 years ago

First of, thanks for creating this package - it's great to finally have a plugin for stylus.

A question: is there some way to preserve line breaks and / or colons. In particular line breaks, as I think they help a lot with readability. Here's an example before/after:

Screenshot 2022-07-29 at 16 25 32 Screenshot 2022-07-29 at 16 25 38

Again, thanks very much for creating this!

lsdsjy commented 2 years ago

Colons are now by default omitted, because Stylus embraces what's called "pythonic" style. Maybe later I can add an option to prefer colons and semicolons. Preserving line breaks is important but now Stylus parser just ignores whitespaces. I'll try to look into it.

lsdsjy commented 2 years ago

I think it's solved in 0.0.1-beta.4. Welcome to try it and share your feedback!

philefstat commented 2 years ago

@lsdsjy Thanks very much for your quick response. Having an option to prefer colons would be much appreciated, but I understand 😄 Maybe if I can find the time I'll have a look at how to do that and make a PR.

I tested 0.0.4 (by pulling locally - don't think the npm package has been published yet) and am still seeing some weird behaviour with spacing, though it seems to be working in some files. For context these are all vue SFCs.

Screenshot 2022-07-30 at 13 57 29 Screenshot 2022-07-30 at 13 57 15
lsdsjy commented 2 years ago

Sorry I forgot to publish the package. 😅 I think I should add some test cases for Vue SFC. I'll investigate into it.

lsdsjy commented 2 years ago

I've added a test case for Vue SFC and it seems blank lines are preserved as expected(See https://github.com/lsdsjy/prettier-plugin-stylus/commit/87f22b41c3cf7b1a907cb9c37e4cf53c28e56500). Can you install v0.0.1-beta.4 from npm and try again? If it still doesn't work, can you provide a minimal reproduction then?

philefstat commented 2 years ago

Yep works now, thanks very much!

Though I've spotted another issue: On every save, a new line break is added to the start of the