-
-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(linter/no-control-regex): better diagnostic messages (#6530)
1. Handle plural/singular cases in message and help text 2. Shrink spans in `RegExp` constructors to only cover the regular expression itself.
- Loading branch information
Showing
3 changed files
with
31 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
16 changes: 8 additions & 8 deletions
16
crates/oxc_linter/src/snapshots/no_control_regex@capture-group-indexing.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
--- | ||
source: crates/oxc_linter/src/tester.rs | ||
--- | ||
⚠ eslint(no-control-regex): Unexpected control character(s) | ||
⚠ eslint(no-control-regex): Unexpected control character | ||
╭─[no_control_regex.tsx:1:11] | ||
1 │ const r = /\0/; | ||
· ──── | ||
╰──── | ||
help: Unexpected control character(s) in regular expression: "\0" | ||
help: '\0' is not a valid control character. | ||
|
||
⚠ eslint(no-control-regex): Unexpected control character(s) | ||
⚠ eslint(no-control-regex): Unexpected control character | ||
╭─[no_control_regex.tsx:1:11] | ||
1 │ const r = /[a-z]\1/; | ||
· ───────── | ||
╰──── | ||
help: Unexpected control character(s) in regular expression: "\1" | ||
help: '\1' is not a valid control character. | ||
|
||
⚠ eslint(no-control-regex): Unexpected control character(s) | ||
⚠ eslint(no-control-regex): Unexpected control character | ||
╭─[no_control_regex.tsx:1:11] | ||
1 │ const r = /([a-z])\2/; | ||
· ─────────── | ||
╰──── | ||
help: Unexpected control character(s) in regular expression: "\2" | ||
help: '\2' is not a valid control character. | ||
|
||
⚠ eslint(no-control-regex): Unexpected control character(s) | ||
⚠ eslint(no-control-regex): Unexpected control character | ||
╭─[no_control_regex.tsx:1:11] | ||
1 │ const r = /([a-z])\0/; | ||
· ─────────── | ||
╰──── | ||
help: Unexpected control character(s) in regular expression: "\0" | ||
help: '\0' is not a valid control character. |