eslint-plugin-svelte icon indicating copy to clipboard operation
eslint-plugin-svelte copied to clipboard

Add rule checking for successful style parsing

Open marekdedic opened this issue 2 years ago • 2 comments

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 avatar Jun 19 '23 15:06 marekdedic

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.

baseballyama avatar Jul 17 '23 03:07 baseballyama

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

marekdedic avatar Jul 18 '23 17:07 marekdedic