From 806c1d14025dc6bdc62efc34e55a92e488e51fae Mon Sep 17 00:00:00 2001 From: Alex Riera <54035255+iErKy@users.noreply.github.com> Date: Wed, 9 Oct 2024 04:32:21 +0200 Subject: [PATCH] docs(eslint-plugin): add docs for signal-state-no-arrays-at-root-level (#4549) --- .../signal-state-no-arrays-at-root-level.md | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/projects/ngrx.io/content/guide/eslint-plugin/rules/signal-state-no-arrays-at-root-level.md b/projects/ngrx.io/content/guide/eslint-plugin/rules/signal-state-no-arrays-at-root-level.md index 507888d4bc..dddda7f787 100644 --- a/projects/ngrx.io/content/guide/eslint-plugin/rules/signal-state-no-arrays-at-root-level.md +++ b/projects/ngrx.io/content/guide/eslint-plugin/rules/signal-state-no-arrays-at-root-level.md @@ -10,3 +10,31 @@ signalState should accept a record or dictionary as an input argument. + +## Rule Details + +This rule ensure that a Signal State shouldn't accept an array type at the root level. + +Examples of **correct** code for this rule: + +```ts +const store = withState({ foo: 'bar' }); + +const store = withState({ arrayAsProperty: ['foo', 'bar'] }) + +const initialState = {}; +const store = signalStore(withState(initialState)); +``` + +Examples of **incorrect** code for this rule: + +```ts +const store = withState([1, 2, 3]); + +const store = withState([{ foo: 'bar' }]); + +const store = withState([]); + +const initialState = []; +const store = withState(initialState); +```