Skip to content

prefer-string-replace-all not working with optional chaining #2769

@2754github

Description

@2754github

prefer-string-replace-all ignores test1 but reports test2.
Is this the intended behavior, or should test1 also be reported?

const test1 = (Math.random() < 0.5 ? 'string' : null)?.replace(/\s/g, '');

const test2 = 'string'.replace(/\s/g, '');

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions