Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
xiaoxiangmoe opened this issue Jan 3, 2020 · 2 comments · Fixed by gucong3000/postcss-syntax#45
Closed

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

xiaoxiangmoe opened this issue Jan 3, 2020 · 2 comments · Fixed by gucong3000/postcss-syntax#45
Labels
type: bug a problem with a feature or rule

Comments

@xiaoxiangmoe
Copy link

  • install stylelint.vscode-stylelint extension
  • touch a.cjs file
  • add below content into file
module.exports = {
  'accessor-pairs': [
    'error',
    {
      setWithoutGet: true,
      getWithoutSet: false,
    },
  ],
};

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
Copy link
Member

ntwb commented Jan 4, 2020

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

@BPScott
Copy link
Contributor

BPScott commented Jan 4, 2020

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.

gucong3000/postcss-syntax#45 is a PR to add .cjs support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug a problem with a feature or rule
Development

Successfully merging a pull request may close this issue.

4 participants