-
-
Notifications
You must be signed in to change notification settings - Fork 986
Fix function-url-quotes false positives when URLs require quoting
#8804
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
Fix function-url-quotes false positives when URLs require quoting
#8804
Conversation
Add test cases demonstrating bug stylelint#8544 where the `function-url-quotes: "never"` rule incorrectly flags URLs that require quotes for valid CSS. The failing tests cover three scenarios where quotes are required: - Data URIs with embedded quotes (e.g., SVG with attributes) - URLs containing spaces - URLs containing parentheses These tests currently fail because the rule doesn't check whether quotes are syntactically required before reporting violations. Refs: stylelint#8544 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Fix bug stylelint#8544 where the `function-url-quotes: "never"` rule incorrectly flagged URLs that must be quoted for valid CSS. The rule now detects when quotes are syntactically required and skips reporting violations in those cases. Implementation: - Added `quotesRequired()` helper function that checks for characters requiring quotes (spaces, quotes, parentheses) per CSS specification - Modified `checkArgs()` to extract URL content and check if quotes are required before reporting violations - When quotes are required, the rule returns early and does not report errors or attempt autofix This prevents the rule from generating invalid CSS when autofix is applied to URLs with embedded quotes (e.g., data URIs), spaces, or parentheses. All existing tests continue to pass, and the 6 new test cases now pass. Fixes stylelint#8544 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Update the CommonJS build output for the function-url-quotes rule to include the bug fix from the previous commit. This was generated by running the build process (rollup) which transpiles the ESM source (index.mjs) to CJS format. The generated file includes: - quotesRequired() helper function - Updated checkArgs() logic to detect required quotes - Early return when quotes are syntactically required This ensures the bug fix works for both ESM and CJS consumers of stylelint. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 237614f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
romainmenke
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.
@taearls Thank you for working on this.
I've left a few suggestion to improve this change.
Please take a look when you have time.
function-url-quotes false positives when URLs require quoting
romainmenke
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.
Thank you for applying the feedback @taearls 🙇
I've left a few more suggestions to cover more cases and simplify the code.
|
This PR is packaged and the instant preview is available (237614f). View the demo website. Install it locally: npm i -D https://pkg.pr.new/stylelint@237614f |
romainmenke
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.
Thank you. LGTM 👍
The codecov warning is caused by a redundant null-isch check, but TypeScript requires the check anyway. I think it is fine to merge as-is.
I'll merge this tomorrow to leave other maintainers a bit of time to also take a look.
jeddy3
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, thank you!
| datasource | package | from | to | | ---------- | --------- | ------- | ------- | | npm | stylelint | 16.26.0 | 16.26.1 | ## [v16.26.1](https://github.com/stylelint/stylelint/blob/HEAD/CHANGELOG.md#16261---2025-11-28) It fixes numerous false positive bugs, including many in the `declaration-property-value-no-unknown` rule for the latest CSS specifications. - Fixed: `*-no-unknown` false positives for latest specs by integrating `@csstools/css-syntax-patches-for-csstree` ([#8850](stylelint/stylelint#8850)) ([@romainmenke](https://github.com/romainmenke)). - Fixed: `at-rule-no-unknown` false positives for `@function` ([#8851](stylelint/stylelint#8851)) ([@jeddy3](https://github.com/jeddy3)). - Fixed: `declaration-property-value-no-unknown` false positives for `attr()`, `if()` and custom functions ([#8853](stylelint/stylelint#8853)) ([@jeddy3](https://github.com/jeddy3)). - Fixed: `function-url-quotes` false positives when URLs require quoting ([#8804](stylelint/stylelint#8804)) ([@taearls](https://github.com/taearls)). - Fixed: `selector-pseudo-element-no-unknown` false positives for `::scroll-button()` ([#8856](stylelint/stylelint#8856)) ([@Mouvedia](https://github.com/Mouvedia)).
| datasource | package | from | to | | ---------- | --------- | ------- | ------- | | npm | stylelint | 16.26.0 | 16.26.1 | ## [v16.26.1](https://github.com/stylelint/stylelint/blob/HEAD/CHANGELOG.md#16261---2025-11-28) It fixes numerous false positive bugs, including many in the `declaration-property-value-no-unknown` rule for the latest CSS specifications. - Fixed: `*-no-unknown` false positives for latest specs by integrating `@csstools/css-syntax-patches-for-csstree` ([#8850](stylelint/stylelint#8850)) ([@romainmenke](https://github.com/romainmenke)). - Fixed: `at-rule-no-unknown` false positives for `@function` ([#8851](stylelint/stylelint#8851)) ([@jeddy3](https://github.com/jeddy3)). - Fixed: `declaration-property-value-no-unknown` false positives for `attr()`, `if()` and custom functions ([#8853](stylelint/stylelint#8853)) ([@jeddy3](https://github.com/jeddy3)). - Fixed: `function-url-quotes` false positives when URLs require quoting ([#8804](stylelint/stylelint#8804)) ([@taearls](https://github.com/taearls)). - Fixed: `selector-pseudo-element-no-unknown` false positives for `::scroll-button()` ([#8856](stylelint/stylelint#8856)) ([@Mouvedia](https://github.com/Mouvedia)).
| datasource | package | from | to | | ---------- | --------- | ------- | ------- | | npm | stylelint | 16.26.0 | 16.26.1 | ## [v16.26.1](https://github.com/stylelint/stylelint/blob/HEAD/CHANGELOG.md#16261---2025-11-28) It fixes numerous false positive bugs, including many in the `declaration-property-value-no-unknown` rule for the latest CSS specifications. - Fixed: `*-no-unknown` false positives for latest specs by integrating `@csstools/css-syntax-patches-for-csstree` ([#8850](stylelint/stylelint#8850)) ([@romainmenke](https://github.com/romainmenke)). - Fixed: `at-rule-no-unknown` false positives for `@function` ([#8851](stylelint/stylelint#8851)) ([@jeddy3](https://github.com/jeddy3)). - Fixed: `declaration-property-value-no-unknown` false positives for `attr()`, `if()` and custom functions ([#8853](stylelint/stylelint#8853)) ([@jeddy3](https://github.com/jeddy3)). - Fixed: `function-url-quotes` false positives when URLs require quoting ([#8804](stylelint/stylelint#8804)) ([@taearls](https://github.com/taearls)). - Fixed: `selector-pseudo-element-no-unknown` false positives for `::scroll-button()` ([#8856](stylelint/stylelint#8856)) ([@Mouvedia](https://github.com/Mouvedia)).
| datasource | package | from | to | | ---------- | --------- | ------- | ------- | | npm | stylelint | 16.26.0 | 16.26.1 | ## [v16.26.1](https://github.com/stylelint/stylelint/blob/HEAD/CHANGELOG.md#16261---2025-11-28) It fixes numerous false positive bugs, including many in the `declaration-property-value-no-unknown` rule for the latest CSS specifications. - Fixed: `*-no-unknown` false positives for latest specs by integrating `@csstools/css-syntax-patches-for-csstree` ([#8850](stylelint/stylelint#8850)) ([@romainmenke](https://github.com/romainmenke)). - Fixed: `at-rule-no-unknown` false positives for `@function` ([#8851](stylelint/stylelint#8851)) ([@jeddy3](https://github.com/jeddy3)). - Fixed: `declaration-property-value-no-unknown` false positives for `attr()`, `if()` and custom functions ([#8853](stylelint/stylelint#8853)) ([@jeddy3](https://github.com/jeddy3)). - Fixed: `function-url-quotes` false positives when URLs require quoting ([#8804](stylelint/stylelint#8804)) ([@taearls](https://github.com/taearls)). - Fixed: `selector-pseudo-element-no-unknown` false positives for `::scroll-button()` ([#8856](stylelint/stylelint#8856)) ([@Mouvedia](https://github.com/Mouvedia)).
| datasource | package | from | to | | ---------- | --------- | ------- | ------- | | npm | stylelint | 16.26.0 | 16.26.1 | ## [v16.26.1](https://github.com/stylelint/stylelint/blob/HEAD/CHANGELOG.md#16261---2025-11-28) It fixes numerous false positive bugs, including many in the `declaration-property-value-no-unknown` rule for the latest CSS specifications. - Fixed: `*-no-unknown` false positives for latest specs by integrating `@csstools/css-syntax-patches-for-csstree` ([#8850](stylelint/stylelint#8850)) ([@romainmenke](https://github.com/romainmenke)). - Fixed: `at-rule-no-unknown` false positives for `@function` ([#8851](stylelint/stylelint#8851)) ([@jeddy3](https://github.com/jeddy3)). - Fixed: `declaration-property-value-no-unknown` false positives for `attr()`, `if()` and custom functions ([#8853](stylelint/stylelint#8853)) ([@jeddy3](https://github.com/jeddy3)). - Fixed: `function-url-quotes` false positives when URLs require quoting ([#8804](stylelint/stylelint#8804)) ([@taearls](https://github.com/taearls)). - Fixed: `selector-pseudo-element-no-unknown` false positives for `::scroll-button()` ([#8856](stylelint/stylelint#8856)) ([@Mouvedia](https://github.com/Mouvedia)).
| datasource | package | from | to | | ---------- | --------- | ------- | ------- | | npm | stylelint | 16.26.0 | 16.26.1 | ## [v16.26.1](https://github.com/stylelint/stylelint/blob/HEAD/CHANGELOG.md#16261---2025-11-28) It fixes numerous false positive bugs, including many in the `declaration-property-value-no-unknown` rule for the latest CSS specifications. - Fixed: `*-no-unknown` false positives for latest specs by integrating `@csstools/css-syntax-patches-for-csstree` ([#8850](stylelint/stylelint#8850)) ([@romainmenke](https://github.com/romainmenke)). - Fixed: `at-rule-no-unknown` false positives for `@function` ([#8851](stylelint/stylelint#8851)) ([@jeddy3](https://github.com/jeddy3)). - Fixed: `declaration-property-value-no-unknown` false positives for `attr()`, `if()` and custom functions ([#8853](stylelint/stylelint#8853)) ([@jeddy3](https://github.com/jeddy3)). - Fixed: `function-url-quotes` false positives when URLs require quoting ([#8804](stylelint/stylelint#8804)) ([@taearls](https://github.com/taearls)). - Fixed: `selector-pseudo-element-no-unknown` false positives for `::scroll-button()` ([#8856](stylelint/stylelint#8856)) ([@Mouvedia](https://github.com/Mouvedia)).
Closes #8544.
Changes made:
url()functionsScope note: This PR focuses on fixing the false positive when quotes are required. It does not add validation for proper escaping of URL values.