stylelint: Handle 'Unexpected "space" found.' Error better

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

There is a bug in stylelint when parsing some files where it throws an Unexpected "space" found. error.

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

Apparently this is a bug in the following rules:

  • selector-type-case
  • selector-pseudo-element-case
  • selector-pseudo-class-case

What CSS is needed to reproduce this issue?

.foo {
  -moz-osx-font-smoothing: grayscale
  .bar & {}
}

What stylelint configuration is needed to reproduce this issue?

{
  "rules": {
    "selector-pseudo-element-case": "lower",
    "selector-pseudo-class-case": "lower",
    "selector-type-case": "lower"
  }
}

Note: Any one of the above rules is enough to trigger this.

Which version of stylelint are you using?

v6.2.2

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

CLI and Node API (linter-stylelint)

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

Discovered in SCSS, but shows if the file is parsed as CSS.

What did you expect to happen?

stylelint to catch this error and return it in the normal manner messages are returned, instead of throwing it on up to where stylelint was being called.

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

The following stack trace:

Error: Unexpected "space" found.
    at new error (C:\Temp\github\linter-stylelint_GH166\node_modules\postcss-selector-parser\dist\processor.js:27:23)
    at Parser.error (C:\Temp\github\linter-stylelint_GH166\node_modules\postcss-selector-parser\dist\parser.js:212:15)
    at Parser.pseudo (C:\Temp\github\linter-stylelint_GH166\node_modules\postcss-selector-parser\dist\parser.js:320:18)
    at Parser.parse (C:\Temp\github\linter-stylelint_GH166\node_modules\postcss-selector-parser\dist\parser.js:502:22)
    at Parser.loop (C:\Temp\github\linter-stylelint_GH166\node_modules\postcss-selector-parser\dist\parser.js:470:18)
    at new Parser (C:\Temp\github\linter-stylelint_GH166\node_modules\postcss-selector-parser\dist\parser.js:89:21)
    at Processor.process (C:\Temp\github\linter-stylelint_GH166\node_modules\postcss-selector-parser\dist\processor.js:24:21)
    at C:\Temp\github\linter-stylelint_GH166\node_modules\stylelint\dist\rules\selector-pseudo-element-case\index.js:48:10
    at C:\Temp\github\linter-stylelint_GH166\node_modules\postcss\lib\container.js:110:28
    at C:\Temp\github\linter-stylelint_GH166\node_modules\postcss\lib\container.js:73:26

Note: Originally filed as part of https://github.com/AtomLinter/linter-stylelint/issues/166.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 20 (14 by maintainers)

Commits related to this issue

Most upvoted comments

I think that label was related waiting on the question issue in postcss-selector-parser. I’ve updated the label accordingly 😃