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

feat: Custom property value replacement in lexer.matchProperty #3

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nzakas
Copy link
Member

@nzakas nzakas commented Feb 27, 2025

This change gives us the ability to pass in substitute values for variables when validating a property. The idea is that ESLint could keep track of the last value for any given custom property and pass that into lexer.matchProperty() so that we can actually validate property values containing var() (right now CSSTree just throws an error, which we swallow in the ESLint rule).

Ported from csstree#321
This pull request introduces changes to the lexer to support matching CSS properties that use the var() function. The changes include adding tests for var() handling and modifying the lexer to replace var() tokens with their corresponding values.

Enhancements to var() handling:

Lexer modifications:

  • lib/lexer/Lexer.js: Added the replaceVarTokens function to handle the replacement of var() tokens with their corresponding values. Modified matchSyntax, matchDeclaration, and matchProperty functions to support options for variable values. [1] [2] [3]

@nzakas nzakas marked this pull request as draft March 3, 2025 20:40
@nzakas
Copy link
Member Author

nzakas commented Mar 3, 2025

Can't quite figure out how to get the correct information into the match error. 🤔

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

Successfully merging this pull request may close these issues.

1 participant