stylelint / vscode-stylelint

The official Visual Studio Code extension for Stylelint
https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint
MIT License
315 stars 30 forks source link

stylelint lint Commonjs JavaScript file (.cjs file) #34

Closed xiaoxiangmoe closed 4 years ago

xiaoxiangmoe commented 4 years ago

it show error:

{
    "resource": "/Users/myhome/myproject/a.cjs",
    "owner": "stylelint",
    "code": "CssSyntaxError",
    "severity": 8,
    "message": "Unknown word (CssSyntaxError)",
    "source": "stylelint",
    "startLineNumber": 5,
    "startColumn": 7,
    "endLineNumber": 5,
    "endColumn": 7
}

error will disappear if rename file from a.cjs into a.js.

ntwb commented 4 years ago

Thanks, confirmed, I'm not sure if this is a bug in PostCSS or PostCSS-JSX and will require more investigation

BPScott commented 4 years ago

It sounds like this is is trying to parse a cjs file with the css parser. I suspect the issue is in postcss-syntax, which recognises .js and .mjs files as things that should use the postcss-jsx parser, but doesn't account for .cjs files.

https://github.com/gucong3000/postcss-syntax/pull/45 is a PR to add .cjs support