Skip to content

Synchronous derived stores should not trigger require-stores-init #1073

Closed
@mcous

Description

@mcous

Overview

I've been using the 3.0.0-next version in our Svelte project, and I'm really liking the new recommended set of rules! However, I've had to disable require-stores-init, because it triggered on nearly every single usage of derived.

Proposal

I think require-stores-init makes a lot of sense for writable and readable stores - it's goal seems to be to prevent an implicitly undefined store values. However, I think synchronous derived stores should not trigger the require-stores-init lint. If a derived store is synchronous, there is no risk that its value can be implicitly undefined, because it will run its callback synchronously when it gets its first subscriber.

If you agree with this change, I'm happy to contribute a PR!

Alternatives

Alternatively, I could imagine a configuration option that allows you to selectively enable or disable require-stores-init for each store type. However, I think enforcing this rule on asynchronous derived stores is valuable, so I prefer my proposal above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions