sindresorhus / eslint-plugin-unicorn

More than 100 powerful ESLint rules
MIT License
4.24k stars 367 forks source link

prefer-regexp-test: incorrect autofix for union type #1380

Open JounQin opened 3 years ago

JounQin commented 3 years ago
const pattern: string | RegExp = 'xxx';

// source
'yyy'.match(pattern)

// fixed
pattern.test('yyy')
fisker commented 3 years ago

1152, maybe we should only fix if it's known RegExp?