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

Fix syntax inference with processors #5117

Closed
yaymukund opened this issue Jan 28, 2021 · 3 comments
Closed

Fix syntax inference with processors #5117

yaymukund opened this issue Jan 28, 2021 · 3 comments
Labels
status: ready to implement is ready to be worked on by someone type: bug a problem with a feature or rule

Comments

@yaymukund
Copy link

yaymukund commented Jan 28, 2021

Clearly describe the bug

If your config contains a processor, stylelint no longer uses postcss-syntax to infer the syntax and defaults to the css parser. The change appeared in version 13.4.0. It's not clear to me if it was an oversight or an intended change in behavior, but here's the relevant line:

https://github.com/stylelint/stylelint/pull/4729/files#diff-5383a0a864da5a5ad24b4bae8f44c5574601bd4d145999b1ddc211d3900dd68bL89

I know that there's discussion of deprecating the processor option, but in the meantime I think this could be better documented. I'm happy to submit a docs PR if that sounds good.

Which rule, if any, is the bug related to?

Not related to a specific rule.

What code is needed to reproduce the bug?

// In an scss file, add double slash comments.

What stylelint configuration is needed to reproduce the bug?

{
  "processors": ["stylelint-processor-styled-components", {}]
}

Which version of stylelint are you using?

13.4.1

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

$ stylelint "**/*.scss" --config myconfig.json

Does the bug relate to non-standard syntax (e.g. SCSS, Less etc.)?

Yes, it's related to scss syntax in my case, but in theory would apply to any syntax that a CSS parser would reject.

What did you expect to happen?

Expected no warnings.

What actually happened (e.g. what warnings or errors did you get)?

Error: Unexpected '/'. Escaping special characters with \ may help.
  at ...styles.scss

Thank you for taking a look :)

@jeddy3 jeddy3 changed the title Processors are incompatible with syntax inference Fix syntax inference with processors Feb 6, 2021
@jeddy3 jeddy3 added status: ready to implement is ready to be worked on by someone type: bug a problem with a feature or rule labels Feb 6, 2021
@jeddy3
Copy link
Member

jeddy3 commented Feb 6, 2021

@yaymukund Thanks for the clear report and for using the template.

I've dug into this and it looks like an oversight on my behalf in #4729.

It's only autofix that is incompatible with processors, not custom syntaxes outright. We already have a check for that:

if (options.codeProcessors && options.codeProcessors.length) {
if (stylelint._options.fix) {
console.warn(
'Autofix is incompatible with processors and will be disabled. Are you sure you need a processor?',
);
stylelint._options.fix = false;
}
options.codeProcessors.forEach((codeProcessor) => {
preProcessedCode = codeProcessor(preProcessedCode, source);
});
}

I've labelled the issue as a bug and ready to implement.

@eMerzh
Copy link

eMerzh commented Feb 14, 2023

hello @jeddy3 ...i just notice this issue too while willing to upgrade to v15 ...

is there some work around ? or plan?

thanks a lot :)

@jeddy3
Copy link
Member

jeddy3 commented Feb 14, 2023

@eMerzh You should use a custom syntax rather than processor. See the migration guide.

Thanks for drawing my attention to this issue. I'll close it as it's no longer relevant since we removed processors in 15.0.0.

@jeddy3 jeddy3 closed this as completed Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready to implement is ready to be worked on by someone type: bug a problem with a feature or rule
Development

Successfully merging a pull request may close this issue.

3 participants