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

Make engine code more straightforward #5529

Closed
jeddy3 opened this issue Sep 13, 2021 · 4 comments
Closed

Make engine code more straightforward #5529

jeddy3 opened this issue Sep 13, 2021 · 4 comments
Labels
status: needs discussion triage needs further discussion

Comments

@jeddy3
Copy link
Member

jeddy3 commented Sep 13, 2021

The stylelint code base has grown over time, especially around the engine. How can we untangle that part of the code to make it easier to add features, like overrides, in the future?

Is it something we can do iteratively through refactors or are more substantial changes needed? For example, if providing stylelint as a PostCSS plugin is a cause, then we could drop that in favour of just the Node API and CLI.

(Caveat: the engine is the part of stylelint that I know the least about. I focused on the rules, even from the very beginning.)

I believe @m-allanson's pull request for the browser entry point (and the refactoring that came out of it) is the only work we've done to map out and refactor the internals before, so feel free to share which areas are problematic and any ideas you may have for untangling the code.

Ref: #5521 (comment)

@jeddy3 jeddy3 added the status: needs discussion triage needs further discussion label Sep 13, 2021
@m-allanson
Copy link
Member

Here's a couple of thoughts on this. From memory, so maybe inaccurate.

  1. standalone.js is a good candidate for refactoring. The deep nested promises make it difficult to follow the logic. The module is essentially two different paths to:
stylelint._lintsource().then(() => {
  return stylelint._createStylelintResult();
});

But it's quite tricky to follow the logic through.

A while ago I tried switching the promises over to use await instead. I made some progress before noticing intermittent failures in the cache tests. Some more debugging is needed on that (maybe this is fixed by #5533).

  1. Processors. If it were possible to remove processors some of stylelint's internal logic could be simplified. Processors can modify code on the way in, and results on the way out.

I'm not up to date on processors, but maybe the following statements are true... Syntaxes replace processors? But the CSS-in-JS syntax lacks some features available in the styled-components processor? And the recent addition of Document nodes (in postcss) means it's now possible to create syntaxes to replace the styled components processor?

@jeddy3
Copy link
Member Author

jeddy3 commented Sep 15, 2021

A while ago I tried switching the promises over to use await instead.

Nice. That'd make it easier to grok what's going on in the file.

And the recent addition of Document nodes (in postcss) means it's now possible to create syntaxes to replace the styled components processor?

Yes, we may be able to remove the deprecated processor functionality in favour of only using syntaxes in 14.0.0.

@jeddy3
Copy link
Member Author

jeddy3 commented Sep 25, 2021

As standalone.js and others were refactored in #5542, I'll convert this issue to removing support for processors. The goal is to have a single point of extension (custom-syntaxes) for dealing with non-CSS files.

@jeddy3
Copy link
Member Author

jeddy3 commented Sep 25, 2021

Closing as we have an issue for that already: #3408

@jeddy3 jeddy3 closed this as completed Sep 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs discussion triage needs further discussion
Development

No branches or pull requests

2 participants