Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use stylus-supremacy over rebuilding a complete parser / formatter #19

Open
qnp opened this issue Oct 19, 2024 · 3 comments
Open

Use stylus-supremacy over rebuilding a complete parser / formatter #19

qnp opened this issue Oct 19, 2024 · 3 comments

Comments

@qnp
Copy link

qnp commented Oct 19, 2024

Greetings @lsdsjy,

I'm looking forward to this project for a while. In my previous pipelines, I used stylus-supremacy to format stylus independently of prettier. Yet, a prettier plugin would be very much more convenient.

Stylus-supremacy is a very accomplished project, started a long time ago and recently received more attention since Stylus seems to be reborn, and reached 4.0.0 lately. It is a very advanced parser and formatter and I think prettier-plugin-stylus could benefit from directly using it instead of rewriting an entire parser / formatter.

Do you think it is a suitable direction ? If yes, I would be happy to contribute to your projet by making the necessary developments to use stylus-supremacy.

Best regards

@lsdsjy
Copy link
Owner

lsdsjy commented Oct 28, 2024

Yes that's totally suitable. Based on stylus-supremacy, we can keep up with the ongoing development of Stylus at a lower cost, maintaining our project as a lightweight plugin. And I’d really appreciate your contribution!

@qnp
Copy link
Author

qnp commented Oct 28, 2024

Thanks for your response.

By the meantime, I dug into stylus-supremacy codebase and they are using Stylus lexer exactly as you do in the plugin for the parsing / lexing. So using stylus supremacy for that won't make a difference. Then, stylus supremacy uses its own rules, and conditions, based on its own options, to format the output. The output is made with string concatenating which is quite different from what is done for prettier (which relies on prettier’s internal builder). I wonder if we could use the string output from stylus supremacy, directly to send it to prettier ?

Otherwise, it may be better to author directly in stylus-supremacy a support for prettier plugin 🤔

What's your opinion on that ?

@lsdsjy
Copy link
Owner

lsdsjy commented Oct 29, 2024

I wonder if we could use the string output from stylus supremacy, directly to send it to prettier ?

There's a problem here: If we directly use the string output from stylus-supremacy as the result, we won't be able to handle prettier-ignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants