Skip to content

Commit 4120db6

Browse files
Improved no-useless-assertions rule (#142)
1 parent 7c5908c commit 4120db6

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lib/rules/no-useless-assertions.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export default createRule("no-useless-assertions", {
6969
flagsStr: string,
7070
): RegExpVisitor.Handlers {
7171
const flags = parseFlags(flagsStr)
72-
const flagsWithoutDotAll = parseFlags(flagsStr.replace(/s/g, ""))
7372

7473
/** Report */
7574
function report(
@@ -115,18 +114,15 @@ export default createRule("no-useless-assertions", {
115114
} else {
116115
// only if the character is a sub set of /./, will the assertion trivially reject
117116

118-
// with this little flag hack, we can easily create the dot set.
119-
const dot = Chars.lineTerminator(
120-
flagsWithoutDotAll,
121-
).negate()
117+
const lineTerminator = Chars.lineTerminator(flags)
122118

123-
if (next.char.isSubsetOf(dot)) {
119+
if (next.char.isDisjointWith(lineTerminator)) {
124120
report(
125121
assertion,
126122
"alwaysRejectByNonLineTerminator",
127123
{ followedOrPreceded },
128124
)
129-
} else if (next.char.isDisjointWith(dot)) {
125+
} else if (next.char.isSubsetOf(lineTerminator)) {
130126
report(assertion, "alwaysAcceptByLineTerminator", {
131127
followedOrPreceded,
132128
})

0 commit comments

Comments
 (0)