Skip to content

unicorn/prefer-regexp-test gives false positives with RTK's .match #2839

@AmarMuric04

Description

@AmarMuric04

Doing a huge refactor after adding the unicorn eslint to my project, the unicorn/prefer-regexp-test rule threw a lot of false positives in many places where I was using the .match from RTK's slices which are in no way related to RegExp .match method.

The buggy rule is unicorn/prefer-regexp-test

Here's a snippet:

liquidityFormSlice.actions.refetch.match(action) ? wait(1000) : Promise.resolve()
// Prefer `RegExp#test(…)` over `String#match(…)`.eslint[unicorn/prefer-regexp-test](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-regexp-test.md)

liquidityFormSlice is just an object returned from RTK's createSlice method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions