Skip to content

Files

Latest commit

 

History

History
76 lines (53 loc) · 2.27 KB

comment-directive.md

File metadata and controls

76 lines (53 loc) · 2.27 KB

Pattern: Unsupported comment-directive in HTML template

Issue: -

Description

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 />

🔧 Options

{
  "svelte/comment-directive": [
    "error",
    {
      "reportUnusedDisableDirectives": false
    }
  ]
}
  • reportUnusedDisableDirectives ... If true, to report unused eslint-disable HTML comments. default false

{ "reportUnusedDisableDirectives": true }

<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 />

📚 Further Reading

🚀 Version

This rule was introduced in eslint-plugin-svelte v0.0.13

🔍 Implementation