# svelte/require-stores-init

require initial value in store

# 📖 Rule Details

This rule is aimed to enforce initial values when initializing the Svelte stores.

/* eslint svelte/require-stores-init: "error" */

import { writable, readable, derived } from 'svelte/store';

/* ✓ GOOD */
export const w1 = writable(false);
export const r1 = readable({});
export const d1 = derived([a, b], () => {}, false);

/* ✗ BAD */
export const w2 = 
Always set a default value for svelte stores. (svelte/require-stores-init)
writable()
;
export const r2 =
Always set a default value for svelte stores. (svelte/require-stores-init)
readable()
;
export const d2 =
Always set a default value for svelte stores. (svelte/require-stores-init)
derived([a, b], () => {})
;

# 🔧 Options

Nothing.

# ❤️ Compatibility

This rule was taken from @tivac/eslint-plugin-svelte.
This rule is compatible with @tivac/svelte/stores-initial-value rule.

# 🚀 Version

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

# 🔍 Implementation