Skip to content

Conversation

@taearls
Copy link
Contributor

@taearls taearls commented Oct 11, 2025

Which issue, if any, is this issue related to?

Closes #8544.

Is there anything in the PR that needs further explanation?

Changes made:

  • Added test cases covering the bug (unquoted URLs with special characters that require quotes)
  • Fixed the rule to not report errors when quotes are required in url() functions

Scope note: This PR focuses on fixing the false positive when quotes are required. It does not add validation for proper escaping of URL values.

taearls and others added 3 commits October 11, 2025 12:07
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-bot
Copy link

changeset-bot bot commented Oct 11, 2025

🦋 Changeset detected

Latest commit: 237614f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
stylelint Patch

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

@taearls taearls changed the title 8544/fix/function url quotes false positive fix (Issue #8544): function-url-quotes false positive Oct 11, 2025
Copy link
Member

@romainmenke romainmenke left a 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.

@romainmenke romainmenke changed the title fix (Issue #8544): function-url-quotes false positive Fix function-url-quotes false positives when URLs require quoting Oct 11, 2025
@taearls taearls requested a review from romainmenke October 18, 2025 09:13
Copy link
Member

@romainmenke romainmenke left a 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.

@taearls taearls requested a review from romainmenke October 21, 2025 20:47
@github-actions
Copy link
Contributor

github-actions bot commented Nov 26, 2025

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

Copy link
Member

@romainmenke romainmenke left a 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.

Copy link
Member

@jeddy3 jeddy3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@jeddy3 jeddy3 merged commit 4b9c68b into stylelint:main Nov 27, 2025
16 of 17 checks passed
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Nov 29, 2025
| 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)).
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Nov 30, 2025
| 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)).
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Dec 1, 2025
| 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)).
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Dec 2, 2025
| 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)).
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Dec 4, 2025
| 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)).
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Dec 4, 2025
| 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)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Fix function-url-quotes false positives when URLs require quoting

3 participants