Skip to content

'e18e/prefer-array-fill' incorrectly errors when the callback is not constantΒ #71

@yharaskrik

Description

@yharaskrik

We use Array.fill for example this way:

const veryLongItems = Array.from({ length: 5 }, () => faker.lorem.sentences(3));

This ensures that the array elements are all different sentences. Right now the plugin is determining that that breaks the rule even though it is not a constant value.

For example this IS wrong:

const sentence =  faker.lorem.sentences(3);

const veryLongItems = Array.from({ length: 5 }, () => sentence);

Since the sentence never changes, but when using a callback with a function call inside that could return a different value, that should not break the rule.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions