eslint-plugin-svelte
eslint-plugin-svelte copied to clipboard
Add rule checking for successful style parsing
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
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.
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