stylelint-custom-processor-loader icon indicating copy to clipboard operation
stylelint-custom-processor-loader copied to clipboard

Allow specifying syntax

Open cdauth opened this issue 6 years ago • 8 comments
trafficstars

When using stylelint-custom-processor-loader with styled-components, the syntax parameter needs to be set to scss, otherwise some language features will not work (such as inline comments, see styled-components/stylelint-processor-styled-components#195).

It would be nice if the syntax parameter could be specified in the config object of the loader.

cdauth avatar Feb 26 '19 15:02 cdauth

That shouldn't be a problem no, see https://github.com/styled-components/stylelint-processor-styled-components/pull/171 and https://github.com/styled-components/stylelint-processor-styled-components/issues/170

We initially thought so too but were enlightened by @jeddy3 from Stylelint.

If you have any other information than this feel free to share it but otherwise I'm closing this

emilgoldsmith avatar Feb 26 '19 16:02 emilgoldsmith

I'm getting lost in docs.

My inline comments are triggering errors when I use this loader, how can I solve it then? When running stylelint manually, I can fix it by specifying --syntax scss.

cdauth avatar Feb 26 '19 16:02 cdauth

The issue styled-components/stylelint-processor-styled-components#170 that you are linking simply explains the fact that the syntax property is not supported in the .stylelintrc config file. But it is still supported and I believe also necessary as a CLI/API parameter.

cdauth avatar Feb 26 '19 16:02 cdauth

We initially thought so too but were enlightened by @jeddy3 from Stylelint.

I'm afraid I might have been wrong. The default PostCSS parser supports the interpolation and nesting I tried in https://github.com/styled-components/stylelint-processor-styled-components/issues/170#issuecomment-370135195, but I don't think it supports inline comments.

As such, users might need to set the syntax to SCSS to use inline comments.

jeddy3 avatar Feb 27 '19 17:02 jeddy3

Hmm okay @jeddy3. But if I recall correctly you said that setting the 'syntax' option in config simply didn't exist and it was only a CLI option? Or is that misremembered by me / outdated information?

emilgoldsmith avatar Feb 28 '19 04:02 emilgoldsmith

It cannot be specified in the stylelintrc config file, but it can be in the options of the API call, as documented here.

cdauth avatar Feb 28 '19 04:02 cdauth

Yes of course, @cdauth if you'd like to submit a PR I'll be happy to review it and publish a new version. But I have a lot of things going on so I won't have the time to implement it myself at the moment

emilgoldsmith avatar Feb 28 '19 06:02 emilgoldsmith

Hmm okay @jeddy3. But if I recall correctly you said that setting the 'syntax' option in config simply didn't exist and it was only a CLI option

That's correct. It can't be set in the configuration object but it can be set using CLI or, as @cdauth pointed out, using the Node.js API.

jeddy3 avatar Feb 28 '19 11:02 jeddy3