Skip to content

Files

Latest commit

 

History

History
42 lines (26 loc) · 1.14 KB

prefer-destructured-store-props.md

File metadata and controls

42 lines (26 loc) · 1.14 KB

Pattern: Missing use of destructured store prop

Issue: -

Description

This rule reports on directly accessing properties of a store containing an object in templates. These usages can instead be written as a reactive statement using destructuring to allow for more granular change-tracking and reduced redraws in the component.

<script>
  /* eslint svelte/prefer-destructured-store-props: "error" */
  import store from './store.js';
  $: ({ foo } = $store);
</script>

<!-- ✓ GOOD -->
{foo}

<!-- ✗ BAD -->
{$store.foo}

🔧 Options

Nothing

❤️ Compatibility

This rule was taken from @tivac/eslint-plugin-svelte.
This rule is compatible with @tivac/svelte/store-prop-destructuring rule.

🚀 Version

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

🔍 Implementation