sveltejs / eslint-plugin-svelte

ESLint plugin for Svelte using AST
https://sveltejs.github.io/eslint-plugin-svelte/
MIT License
287 stars 33 forks source link

`svelte/valid-compile` error happens for `enhanced:img` #809

Closed ryoppippi closed 1 month ago

ryoppippi commented 1 month ago

Before You File a Bug Report Please Confirm You Have Done The Following...

What version of ESLint are you using?

9.5.0

What version of eslint-plugin-svelte are you using?

2.41.0

What did you do?

Configuration ``` 'svelte/valid-each-key': 'error', ```
<enhanced:img alt='An alt text' src='./path/to/your/image.jpg' />

and got diagnostics like below:

Diagnostics:
1. Self-closing HTML tags for non-void elements are ambiguous — use `<enhanced:img ...></enhanced:img>` rather than `<enhanced:img ... />`(element_invalid_self_closing_tag) [svelte/valid-compile]
2. Self-closing HTML tags for non-void elements are ambiguous — use `<enhanced:img ...></enhanced:img>` rather than `<enhanced:img ... />` [element_invalid_self_closing_tag]

What did you expect to happen?

When using <img /> instead of <enhanced:img />, it works fine.

What actually happened?

Got weird diagnostics

Additional comments

https://kit.svelte.dev/docs/images

ryoppippi commented 1 month ago

I had a discussion with @baseballyama and svelte/valid-compile is not needed in my use case So I close this. Thanks!

baseballyama commented 1 month ago

@ota-meshi As Svelte is a compiler, it may not compile correctly without a pre-processor. <enhanced:img> is an example. How should this be addressed? My opinion is that we could deprecate this rule in the next major version release, but I'm sure you have a better idea.

ota-meshi commented 1 month ago

In my opinion, I think the valid-compile rule is unnecessary and can be deprecated, because the same errors can be displayed more accurately if you use Svelte compilation instead of ESLint. The rule was created for the purpose of displaying the same errors as eslint-plugin-svelte3. (eslint-plugin-svelte3 displayed Svelte compilation errors as lint errors.)

However, we still need tasks that compile with Svelte because of the no-unused-svelte-ignore rule. I don't know yet if the preprocessor affects it. https://sveltejs.github.io/eslint-plugin-svelte/rules/no-unused-svelte-ignore/