Skip to content

Commit 5f67457

Browse files
committed
Fix false positives for space in RegExp constructor in regexp/no-invisible-character rule (#244)
1 parent ff3714d commit 5f67457

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/rules/no-invisible-character.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ export default createRule("no-invisible-character", {
6868

6969
let index = 0
7070
for (const c of text) {
71+
if (c === " ") {
72+
continue
73+
}
7174
const cp = c.codePointAt(0)!
7275
if (isInvisible(cp)) {
7376
const instead = toCharSetSource(cp, flags)

tests/lib/rules/no-invisible-character.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ tester.run("no-invisible-character", rule as any, {
1919
`
2020
const a = '' + '\t';
2121
new RegExp(a)`,
22+
"new RegExp(' ')",
23+
"new RegExp('a')",
24+
"new RegExp('[ ]')",
2225
],
2326
invalid: [
2427
{

0 commit comments

Comments
 (0)