-
-
Notifications
You must be signed in to change notification settings - Fork 32
feat: make var() regex multiline-safe in no-invalid-properties
#242
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: make var() regex multiline-safe in no-invalid-properties
#242
Conversation
no-invalid-properties
no-invalid-propertiesno-invalid-properties
|
Changed the tag to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify the change in behavior: the new regex matches var()'s with newlines in or after the fallback text (between the fallback text and the closing parenthesis), which the old regex didn't match.
| ":root { --fallback-color: blue; }\na { color: VAR(--MY-COLOR, VaR(--fallback-color)) }", | ||
| "a { color: var(--my-color,\n red) }", | ||
| ":root { --my-color: red; }\na { color: var(--my-color,\n blue) }", | ||
| "a { color: var(--x,\n var(--y,\n blue\n )\n) }", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one was invalid before this change (false positive).
| ":root { --my-color: red; }\na { color: var(--my-color,\n blue) }", | ||
| "a { color: var(--x,\n var(--y,\n blue\n )\n) }", | ||
| "a { color: var(--x,\n red ) }", | ||
| ":root { --a: var(--b,\n 10px\n); } a { padding: var(--a); }", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one was invalid before this change (false positive).
| { | ||
| code: "a { padding-top: var(--a,\nvar(--b, red\n)\n); }", | ||
| options: [{ allowUnknownVariables: true }], | ||
| errors: [ | ||
| { | ||
| messageId: "invalidPropertyValue", | ||
| data: { | ||
| property: "padding-top", | ||
| value: "red", | ||
| expected: "<length-percentage [0,∞]>", | ||
| }, | ||
| line: 1, | ||
| column: 18, | ||
| endLine: 4, | ||
| endColumn: 2, | ||
| }, | ||
| ], | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one was valid before this change (false negative).
mdjermanovic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! Leaving open for a second review.
nzakas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
Prerequisites checklist
What is the purpose of this pull request?
Fix the
var()parsing to handle multiline fallbacks safely and avoid super-linear backtracking.What changes did you make? (Give an overview)
Related Issues
#229 (comment)
Is there anything you'd like reviewers to focus on?