ota-meshi / eslint-plugin-regexp

ESLint plugin for finding regex mistakes and style guide violations.

Home Page:https://ota-meshi.github.io/eslint-plugin-regexp/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`no-useless-assertions` false negative around `$`

RunDevelopment opened this issue · comments

#478 included the regex: /Java(?=Script)$/. This regex will always reject because the 2 assertions conflict each other. no-useless-assertions is supposed to report this but doesn't. The rule does find the problem in /Java$(?=Script)/ though.

image
image

I've found other false negatives for no-useless-assertions.
( I thought I'd open a new issue, but commenting on this issue because I thought it was similar to this issue. Let me know if you think it should be a separate issue.)

The following patterns contain assertions that are always accepted, but none are reported.

console.log(/^^a$$/u.test('a'));
//            ^  ^  second edge assertions will always accept
console.log(/\b^a\b$/u.test('a'));
//           ^^  ^^  \b will always accept
console.log(/^\ba$\b/u.test('a'));
//            ^^  ^^  \b will always accept
console.log(/\b\ba\b\b/u.test('a'));
//             ^^   ^^  second \b will always accept

https://ota-meshi.github.io/eslint-plugin-regexp/playground/#eJyVkNEKgzAMRX+lBEGFaWGP7ldKIdMgQmnFVNwQ/32ZDrY9TFlJbyDcnlsyQx0agkqa5+CodKHNtLWYJHosI3HMUkzz/GK81urj2LWY5F2jqGlJITMNsROOmjrnFLoJ76ywrqmPxn8FGHO1KLIfYu12xXiMtOLCROTg3/8wxfSkbm2fu0JXee3kVwCcYBgdMVQzDNTSrdc+FCOTzLh4LxGq87I8ANfpgiU=