Skip to content

Commit 730b635

Browse files
Fix no-useless-lazy false negative (#335)
1 parent 9cc53a1 commit 730b635

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

lib/rules/no-useless-lazy.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,7 @@ export default createRule("no-useless-lazy", {
102102
matchingDir,
103103
flags,
104104
)
105-
if (
106-
!after.edge &&
107-
firstChar.char.isDisjointWith(after.char)
108-
) {
105+
if (firstChar.char.isDisjointWith(after.char)) {
109106
context.report({
110107
node,
111108
loc: getLazyLoc(regexpContext, qNode),

tests/lib/rules/no-useless-lazy.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,26 @@ tester.run("no-useless-lazy", rule as any, {
8282
output: `/(?:a|cd)+(?:b+|zzz)/`,
8383
errors: [{ messageId: "possessive" }],
8484
},
85+
86+
{
87+
code: String.raw`/\b\w+?(?=\W)/`,
88+
output: String.raw`/\b\w+(?=\W)/`,
89+
errors: [{ messageId: "possessive" }],
90+
},
91+
{
92+
code: String.raw`/\b\w+?(?!\w)/`,
93+
output: String.raw`/\b\w+(?!\w)/`,
94+
errors: [{ messageId: "possessive" }],
95+
},
96+
{
97+
code: String.raw`/\b\w+?\b/`,
98+
output: String.raw`/\b\w+\b/`,
99+
errors: [{ messageId: "possessive" }],
100+
},
101+
{
102+
code: String.raw`/\b\w+?$/`,
103+
output: String.raw`/\b\w+$/`,
104+
errors: [{ messageId: "possessive" }],
105+
},
85106
],
86107
})

0 commit comments

Comments
 (0)