Skip to content

Conversation

@lionel-rowe
Copy link

Fixes #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 0x00 is rendered \x00 not \x0
  • Added \x7f DEL to the detected control chars

@CLAassistant
Copy link

CLAassistant commented Nov 7, 2024

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rule suggestion: remove no-control-regex from defaults

2 participants