8000 Suggestion: Document usage of postcss-rewrite-url with Stylelint · Issue #1524 · csstools/postcss-plugins · GitHub
Skip to content

Suggestion: Document usage of postcss-rewrite-url with Stylelint #1524

Closed
@ehoogeveen-medweb

Description

@ehoogeveen-medweb

I was examining our (somewhat neglected) Stylelint config recently and found declaration-property-value-no-unknown, which IIUC may be enabled by default soon. Enabling this rule turned out to be very helpful for us, finding a number of bugs in our CSS :)

However, it took me a while to figure out how to make it work with rewrite-url(). Eventually I came up with this (the function-no-unknown exception is included for completeness):

{
  "rules": {
    "declaration-property-value-no-unknown": [
      true,
      {
        "typesSyntax": {
          "url": "| rewrite-url( <string> )"
        }
      }
    ],
    "function-no-unknown": [
      true,
      {
        "ignoreFunctions": ["rewrite-url"]
      }
    ],
  }
}

This extends <url> to also accept rewrite-url() type values, which may be somewhat overly broad but works like a charm for us. Technically url() takes url( <string> <url-modifier>* ) but I wasn't sure if rewrite-url() supports these (theoretical?) modifiers.

What do you think?

Metadat 3DEE a

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions