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

Add stylelintType: "parseError" when parseSelector fails #858

Merged

Conversation

wlewis-formative
Copy link
Contributor

Without this, I believe parse errors are being treated as warnings by stylelint. Updating this to match e.g. the parseSelector function in stylelint causes them to be treated as errors.

To reproduce

  • git clone git@github.com:wlewis-formative/stylelint-scss-min-repro.git
  • Run npm lint
  • Run echo $?

The exit code is 0, even though errors were reported:

$ npm run lint

> stylelint-scss-min-repro@0.0.1 lint
> stylelint Bad.tsx


Bad.tsx
 4:3  ✖  Cannot parse selector

1 problem (1 error, 0 warnings)

$ echo $?
0

This issue occurs because postcss-styled-syntax is parsing inline comments as selectors instead of reporting an error. The error is only discovered later (here).

@wlewis-formative wlewis-formative changed the title Add styleLintType: "parseError" when parseSelector fails Add stylelintType: "parseError" when parseSelector fails Sep 21, 2023
@wlewis-formative wlewis-formative changed the title Add stylelintType: "parseError" when parseSelector fails Add stylelintType: "parseError" when parseSelector fails Sep 21, 2023
@kristerkari
Copy link
Collaborator

@wlewis-formative Thanks for this one! I have just one question in mind: do you know if this change is backwards compatible to the current minimum supported version (14.5.1) of this package?

@wlewis-formative
Copy link
Contributor Author

I think so. I checked out the commit with the tag 14.5.1 (git checkout tags/14.5.1) in the stylelint repo, and both parseSelector and transformSelector call result.warn with stylelintType: 'parseError':

} catch {
  result.warn('Cannot parse selector', { node, stylelintType: 'parseError' });
  //                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
}

@kristerkari
Copy link
Collaborator

@wlewis-formative Great, thanks for checking! I think that this is good to go then 👍

@kristerkari kristerkari merged commit 2a595b3 into stylelint-scss:master Oct 24, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants