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 rule checking for successful style parsing #509

Open
marekdedic opened this issue Jun 19, 2023 · 2 comments
Open

Add rule checking for successful style parsing #509

marekdedic opened this issue Jun 19, 2023 · 2 comments
Labels
enhancement New feature or request new rule

Comments

@marekdedic
Copy link
Contributor

Motivation

With the recent edition of a rule that uses the parsed styles (#489), this rule in fact doesn't produce any errors if the styles cannot be parsed (either they're invalid, or svelte-eslint-parser cannot parse the used style language)

Description

I propose a rule that would produce a warning in either of these 2 cases (parse error / unknown language). This would guarantee that rules using styles (currently only no-unused-class-name) work correctly. There's also a minor overlap with the block-lang rule, but I think this is OK

Examples

<!-- ✓ GOOD -->
<style>
  .class {
    font-weight: bold;
  }
</style>

<style lang="scss">
  .class {
    font-weight: bold;
  }
</style>

<!-- ✗ BAD -->
<style>
  .class
    font-weight: bold;
</style>

<style lang="unknown">
  .class {
    font-weight: bold;
  }
</style>

Additional comments

No response

@marekdedic marekdedic added enhancement New feature or request new rule labels Jun 19, 2023
@baseballyama
Copy link
Member

I have a question.
Is this not detected by the preprocessor or something?
I thought that the preprocessor already has a parser such as SCSS or LESS etc, so if it failed to parse it would get some kind of error.

@marekdedic
Copy link
Contributor Author

Some of it may as well be detected by the preprocessor, but svelte-eslint-parser for example can't read LESS (yet ;) ), so it would be useful to know that rules depending on style parsing are turned off in this case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new rule
Projects
None yet
Development

No branches or pull requests

2 participants