openstyles / stylus

Stylus - Userstyles Manager
https://add0n.com/stylus.html
GNU General Public License v3.0
5.35k stars 302 forks source link

[Bug] [Preprocessor: Stylus] Incorrect Line Hints & "Beautify" #1721

Closed cyfung1031 closed 9 months ago

cyfung1031 commented 9 months ago

Example Styles:

1. Incorrect Hints

Screen Shot 2023-12-23 at 10 00 32

It always show a red cross in the editor. But actually there is no problem in the code as it is @preprocessor stylus

2. It cannot beautify. The code will be broken.

Before

Screen Shot 2023-12-23 at 10 04 11

After

Screen Shot 2023-12-23 at 10 02 20

"beautify" will break the stylus features. At this moment, I need to add a empty comment // at the end of each line to prevent the breaking.

tophf commented 9 months ago

Yes, these are known issues with stylelint and beautifier, I can only hope they will be resolved upstream someday.

  1. You can disable CSS Linter to hide the error.
  2. You can use a standard comment and an external beautifier.

See also #880.

cyfung1031 commented 9 months ago

I can only hope they will be resolved upstream someday.

Any Github Repo for the upstream?

tophf commented 9 months ago

Disregard that. The first problem is #880. The beautifier upstream repo is semi-abandoned so it doesn't matter and I don't know any modern CSS beautifiers that can be compiled as a small bundle.

cyfung1031 commented 9 months ago

Disregard that. The first problem is #880. The beautifier upstream repo is semi-abandoned so it doesn't matter and I don't know any modern CSS beautifiers that can be compiled as a small bundle.

https://github.com/openstyles/stylus/blob/master/vendor-overwrites/beautify/ https://github.com/openstyles/stylus/blob/master/vendor-overwrites/beautify/beautify-css-mod.js

You means this right? Would you mind PRs for this file?

tophf commented 9 months ago

Sure.

tophf commented 9 months ago

I think though it should be rewritten entirely, either using parserlib or postcss from our stylelint-bundle (it's not exposed currently, but we can expose it).