deno_lint
deno_lint copied to clipboard
fix(no-control-regex): Only warn on control char literals
Fixes https://github.com/denoland/deno_lint/issues/1143.
Old and new behavior both diverge from ESLint but in different ways:
- ESLint detects both control char escapes and control char literals
- Old deno_lint behavior only detected control char escapes but failed to detect control char literals
- New deno_lint behavior only detects control char literals and intentionally overlooks control char escapes (reasoning per the linked issue)
In all cases (including ESLint), the checking is done against the regex source string rather than the JS/TS source code. This gives the following behavior:
| JS/TS source code | ESLint | deno_lint old |
deno_lint new |
|---|---|---|---|
// (literal 0x1f char) |
⚠️ | 🆗 | ⚠️ |
/\x1f/ |
⚠️ | ⚠️ | 🆗 |
new RegExp('') (literal 0x1f char) |
⚠️ | 🆗 | ⚠️ |
new RegExp('\x1f') |
⚠️ | 🆗 | ⚠️ |
new RegExp('\\x1f') |
⚠️ | ⚠️ | 🆗 |
Also fixes the following 2 bugs noted in the linked issue:
- Formatting of the message fixed such that code point
0x00is rendered\x00not\x0 - Added \x7f DEL to the detected control chars