Refactor CSSTree lexer creation#9067
Merged
Merged
Conversation
This simplifies how to create the CSSTree `Lexer` instance. - Unify `getLexer()` in `lib/utils/getLexer.mjs` and `getCachedLexer()` in `lib/lintPostcssResult.mjs` - Now, `getLexer()` returns a cached `Lexer` instance based on `config.languageOptions.syntax` - Add the `result.stylelint.lexer` property for each rule implementation - Remove the internal `context.lexer` property that is no longer needed Thus, each rule implementation can access the `Lexer` instance more easily. Note that this refactoring idea was inspired by this discussion: #9062 (comment)
|
Contributor
|
This PR is packaged and the instant preview is available (95cdf35). View the demo website. Install it locally: npm i -D https://pkg.pr.new/stylelint@95cdf35 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #9062
This PR simplifies how to create the CSSTree
Lexerinstance.getLexer()inlib/utils/getLexer.mjsandgetCachedLexer()inlib/lintPostcssResult.mjsgetLexer()returns a cachedLexerinstance based onconfig.languageOptions.syntaxresult.stylelint.lexerproperty for each rule implementationcontext.lexerproperty that is no longer neededThus, each rule implementation can access the
Lexerinstance more easily.Note that this refactoring idea was inspired by this discussion: #9062 (comment)