# svelte/experimental-require-strict-events

require the strictEvents attribute on <script> tags

# 📖 Rule Details

This rule enforces the presence of the strictEvents attribute on the main <script> tag of all components. This attributes enforces typechecking of events dispatched by the component, e.g. making it a typescript error to listen to any non-existent events. Alternatively, the event types may be defined manually by declaring the $$Events interface. The strictEvents attribute and the $$Events interface are experimental and are documented in svelte RFC #38.

<!-- ✓ GOOD -->
<script lang="ts" strictEvents>
  /* eslint svelte/experimental-require-strict-events: "error" */
</script>
<!-- ✓ GOOD -->
<script lang="ts">
  /* eslint svelte/experimental-require-strict-events: "error" */
  
Parsing error: The keyword 'interface' is reserved
i
nterface $$Events {}
</script>
<!-- ✗ BAD -->
The component must have the strictEvents attribute on its <script> tag or it must define the $$Events interface. (svelte/experimental-require-strict-events)
<script lang="ts">
/* eslint svelte/experimental-require-strict-events: "error" */ </script>

# 🔧 Options

Nothing.

# 🚀 Version

This rule was introduced in eslint-plugin-svelte v2.18.0

# 🔍 Implementation