Hi there, the prefer-regexp-test
rule is giving me a false positive with code similar to this:
import { createAction, Action } from '@reduxjs/toolkit'
const increment = createAction<number>('INCREMENT')
function someFunction(action: Action) {
if (increment.match(action)) {
// ^ Prefer `RegExp#test(…)` over `String#match(…)`.
}
}
increment
in this snippet is not a string -- the match()
method is part of the Redux Toolkit api and works as a TypeScript type guard.
It's a little unfortunate, but I don't suppose there's any way to avoid this error besides disabling the rule? It would probably need type information, like some of the @typescript-eslint/eslint-plugin rules, eslint-plugin-sonarjs rules, etc.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too