Pattern: Unsupported comment-directive in HTML template
Issue: -
ESLint doesn't provide any API to enhance eslint-disable
functionality and ESLint rules cannot affect other rules. But ESLint provides processors API.
This rule sends all eslint-disable
-like comments to the post-process of the .svelte
file processor, then the post-process removes the reported errors in disabled areas.
<script>
/* eslint svelte/comment-directive: "error", no-undef: "error" */
</script>
<!-- eslint-disable-next-line no-undef -->
<UndefComponent />
The eslint-disable
-like comments can include descriptions to explain why the comment is necessary. The description must occur after the directive and is separated from the directive by two or more consecutive -
characters. For example:
<script>
/* eslint svelte/comment-directive: "error", no-undef: "error" */
</script>
<!-- eslint-disable-next-line no-undef -- Here's a description about why this disabling is necessary. -->
<UndefComponent />
{
"svelte/comment-directive": [
"error",
{
"reportUnusedDisableDirectives": false
}
]
}
reportUnusedDisableDirectives
... Iftrue
, to report unusedeslint-disable
HTML comments. defaultfalse
<script>
/* eslint svelte/comment-directive: ["error", { "reportUnusedDisableDirectives": true }], no-undef: "error" */
import DefinedComponent from './DefinedComponent.svelte';
</script>
<!-- ✓ GOOD -->
<!-- eslint-disable-next-line no-undef -->
<UndefComponent />
<!-- ✗ BAD -->
<!-- eslint-disable-next-line no-undef -->
<DefinedComponent />
This rule was introduced in eslint-plugin-svelte v0.0.13