stylelint: Add ignore: ["default-namespace"] and ignoreNamespaces: [] options to selector-type-no-unknown

Describe the issue. Is it a bug or a feature request (new rule, new option, etc.)?

The selector-type-no-unknown rule doesn’t take CSS namespace into account.

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

selector-type-no-unknown

What CSS is needed to reproduce this issue?

e.g.


@namespace todomvc url(urn:app:todomvc);

todomvc|app {
    display: block;
    position: absolute;
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
}

What stylelint configuration is needed to reproduce this issue?

e.g.

{
    "extends": "stylelint-config-standard",
    "rules": {
        "selector-type-no-unknown": [true, { "severity": "warning" }]
    }
}

Which version of stylelint are you using?

7.8.0

How are you running stylelint: CLI, PostCSS plugin, Node API?

CLI with stylelint **/*.css

Does your issue relate to non-standard syntax (e.g. SCSS, nesting, etc.)?

No. CSS namespaces are a W3C-approved syntax.

What did you expect to happen?

“No warnings to be flagged.”

What actually happened (e.g. what warnings or errors you are getting)?

“The following warnings were flagged:”

   12:8    warn    Unexpected unknown type selector "app"                         selector-type-no-unknown

Note that this bug can be fixed by altering selector-type-no-unknown/index.js by inserting this at line 85:

if (optionsMatches(options, "ignoreTypes", tagNode.namespace + '|' + tagNode.value)) {
            return
          }

and then by updating the .stylelintrc to have:

        "selector-type-no-unknown": [true, { 
            "severity": "warning", 
            "ignoreTypes": ["/^.*\\|.*$/"] 
        }],

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (8 by maintainers)

Commits related to this issue

Most upvoted comments

seems slightly incorrect and might be just that you mistyped. Shouldn’t that be [“todomvc”,“other”]?

Yes, it should have been 😃

It would be great if the ignoreNamespaces option could (like the ignoreTypes option) take a RegExp.

Agreed.

I’m about to dash off on holiday. I’ll leave this issue open for discussion while I’m away so that the rest of @stylelint/core can jump in if they’ve any input on the new options. If there aren’t any objections by the time I’m back, I’ll label this up then as type: option and status: help wanted.

@bedney & @idearat FYI, these options are now available in 7.10.0.