Skip to content

Fix declaration-property-value-no-unknown false positives for attr() of every properties #8779

@otomad

Description

@otomad

What minimal example or steps are needed to reproduce the bug?

[data-cursor] {
	cursor: attr(data-cursor type(<custom-ident>), default);
}

[data-anchor] {
	anchor-name: attr(data-anchor type(<custom-ident>));
}

[data-landmark] {
	view-transition-name: attr(data-landmark type(<custom-ident>));
}

What minimal configuration is needed to reproduce the bug?

{
    "rules": {
        "declaration-property-value-no-unknown": true
    }
}

How did you run Stylelint?

Demo

Which Stylelint-related dependencies are you using?

{
	"stylelint": "16.24.0"
}

What did you expect to happen?

No problems to be reported.

What actually happened?

The following problems were reported:

example.css
2:10-57 error Cannot parse property value "attr(data-cursor type(<custom-ident>), default)" for property "cursor" (declaration-property-value-no-unknown)
6:15-53 error Cannot parse property value "attr(data-anchor type(<custom-ident>))" for property "anchor-name" (declaration-property-value-no-unknown)
10:24-64 error Cannot parse property value "attr(data-landmark type(<custom-ident>))" for property "view-transition-name" (declaration-property-value-no-unknown)

Additional Info

For content property, it only supports the fallback value and the unit, but does not support the type. For example:

::after {
	/* The following rules are valid. */
	content: attr(data-content, "fallback");
	content: attr(data-content raw-string);

	/* The following rules will report errors. */
	content: attr(data-content type(<string>));
	content: attr(data-content type(*));
}

Do you have a proposal to fix the bug?

Update syntax in CSSTree.

Sorry, I don't know how to extend the syntax myself using the languageOptions configuration property to support new syntax of attr() of every properties. Can you help me?

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: blockedis blocked by another issue or prupstreamrelates to an upstream package

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions