Skip to content

immutable-data ignoreImmediateMutation option does not work when creating an array with .split() #759

Closed
@QuaidBartolomei

Description

@QuaidBartolomei

Bug Report

the functional/immutable-data rule with ignoreImmediateMutation: true will trigger an error when immediately mutating an array created with the string .split() method

Expected behavior

these rules

      'functional/immutable-data': [
        'error',
        {
          ignoreImmediateMutation: true,
        },
      ]

should allow this code:

const x = ''.split('').pop()

Actual behavior

error:

Modifying an array is not allowed

I know the rules are setup correctly because this does not error:

const x = [].pop()

Steps to reproduce

latest version (6.0.0) with the rule snippet above

Proposed changes

Metadata

Metadata

Assignees

No one assigned

    Labels

    AcceptedThis issue or PR has been accepted.Status: ReleasedIt's now live.Type: BugInconsistencies or issues which will cause a problem for users or implementors.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions