Skip to content
TypeScript

chore(lint): disable eslint/no-control-regex (#25049)

Julius Marminge1cd44f0d555f
diff --git a/apps/mobile/src/features/terminal/terminalInput.ts b/apps/mobile/src/features/terminal/terminalInput.ts
index ced540e615a..33c207173b4 100644
--- a/apps/mobile/src/features/terminal/terminalInput.ts
+++ b/apps/mobile/src/features/terminal/terminalInput.ts
@@ -10,7 +10,6 @@ export type ModifiedTerminalInput =
| { readonly kind: "write"; readonly data: string }
| { readonly kind: "paste" };
-// eslint-disable-next-line no-control-regex -- Pasted text must not carry raw terminal controls.
const UNSAFE_PASTE_BYTES = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g;
export function applyCtrlModifier(input: string): string {
diff --git a/apps/server/src/preview/ServerBrowserPage.ts b/apps/server/src/preview/ServerBrowserPage.ts
index 129eaa8a89b..d3093bb298a 100644
--- a/apps/server/src/preview/ServerBrowserPage.ts
+++ b/apps/server/src/preview/ServerBrowserPage.ts
@@ -174,7 +174,6 @@ export const withoutDataPayload = (url: string) => {
: ({ t: "\t", n: "\n", r: "\r", '"': '"', "\\": "\\" }[code] ?? "\u0001"),
)
.replace(/[\t\n\r]/g, "")
- // eslint-disable-next-line no-control-regex -- URL parsing ignores these controls.
.replace(/^[\u0000-\u0020]+/, "");
const parsed = /^data:([^,;]*)/i.exec(value);
if (!parsed) return url;
diff --git a/apps/server/src/process/externalLauncher.ts b/apps/server/src/process/externalLauncher.ts
index ff62b3ab5a1..45113537ce8 100644
--- a/apps/server/src/process/externalLauncher.ts
+++ b/apps/server/src/process/externalLauncher.ts
@@ -67,7 +67,6 @@ interface TargetPathAndPosition {
}
// cmd shims reparse %* after escaping is gone; newlines and quotes can expose shell operators.
-// oxlint-disable-next-line no-control-regex
const WINDOWS_SHIM_UNSAFE_ARG_PATTERN = /[\u0000-\u001f\u007f"]/;
const TARGET_WITH_POSITION_PATTERN = /^(.*?):(\d+)(?::(\d+))?$/;
const POWERSHELL_ARGUMENTS_PREFIX = [
diff --git a/apps/server/src/project/ProjectSetupScriptRunner.ts b/apps/server/src/project/ProjectSetupScriptRunner.ts
index a2f8e0fc8e2..612bb773d07 100644
--- a/apps/server/src/project/ProjectSetupScriptRunner.ts
+++ b/apps/server/src/project/ProjectSetupScriptRunner.ts
@@ -127,16 +127,12 @@ function completionSentinelPattern(token: string): RegExp {
}
function stripTerminalControl(text: string): string {
- return (
- text
- .replace(
- // eslint-disable-next-line no-control-regex -- ANSI escape sequences start with ESC.
- /\x1b\[[0-9;?]*[ -/]*[@-~]|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b[()][A-Za-z0-9]|\x1b[=>]/g,
- "",
- )
- // eslint-disable-next-line no-control-regex -- removing control characters is the point.
- .replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, "")
- );
+ return text
+ .replace(
+ /\x1b\[[0-9;?]*[ -/]*[@-~]|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b[()][A-Za-z0-9]|\x1b[=>]/g,
+ "",
+ )
+ .replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, "");
}
// Line editors (zsh, fish, bash 5.1+) enable bracketed paste when they start reading a command.
diff --git a/apps/server/src/terminal/Manager.ts b/apps/server/src/terminal/Manager.ts
index 3abfed846c4..5476e7964a4 100644
--- a/apps/server/src/terminal/Manager.ts
+++ b/apps/server/src/terminal/Manager.ts
@@ -1022,7 +1022,6 @@ function neutralizeInheritedHistory(history: string, maxLines: number, maxBytes:
// An unconditional 1049 reset restores a stale saved cursor on the main
// screen. The exit must match the inherited screen's cursor-save behavior.
let alternateScreen: number | undefined;
- // eslint-disable-next-line no-control-regex -- Match replayed alternate-screen controls.
for (const match of history.matchAll(/\u001b(?:\[\?([0-9;]+)([hl])|(c))/gu)) {
if (match[3]) alternateScreen = undefined;
for (const parameter of (match[1] ?? "").split(";")) {
@@ -1120,7 +1119,6 @@ function findEscapeSequenceEndIndex(input: string, start: number): number | null
return isEscapeFinalByte(input.charCodeAt(cursor)) ? cursor + 1 : start + 1;
}
-// eslint-disable-next-line no-control-regex -- Terminal sequence introducers must reach the parser.
const HISTORY_SEQUENCE_START = /[\u001b\u0090\u009b\u009d\u009e\u009f]/;
const NEXT_HISTORY_SEQUENCE_START = new RegExp(HISTORY_SEQUENCE_START.source, "g");
diff --git a/packages/client-runtime/src/work-log/commandLabel.ts b/packages/client-runtime/src/work-log/commandLabel.ts
index 9b7c8d550dd..cd144cf68c5 100644
--- a/packages/client-runtime/src/work-log/commandLabel.ts
+++ b/packages/client-runtime/src/work-log/commandLabel.ts
@@ -1361,7 +1361,6 @@ export function commandProgramName(command: string, depth = 0): string | null {
// Escape bytes and other control characters render as invisible gaps; display
// shows them as Unicode control pictures (ESC becomes ␛) instead. Tab, newline
// and carriage return lay out as whitespace, so CRLF scripts stay unmarked.
-// oxlint-disable-next-line no-control-regex
const CONTROL_CHARACTERS = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/gu;
export function commandDisplayText(command: string): string {
diff --git a/packages/shared/src/promptLinks.ts b/packages/shared/src/promptLinks.ts
index 5be4da23c91..adff0135bfc 100644
--- a/packages/shared/src/promptLinks.ts
+++ b/packages/shared/src/promptLinks.ts
@@ -36,7 +36,7 @@ export type PromptLinkResult<T> =
// Hidden characters let models read instructions invisible to the person reviewing the prompt.
const HIDDEN_CHARACTERS =
- // oxlint-disable-next-line no-control-regex, no-misleading-character-class -- these are the characters it removes.
+ // oxlint-disable-next-line no-misleading-character-class -- these are the characters it removes.
/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\u00AD\u034F\u061C\u115F\u1160\u17B4\u17B5\u180B-\u180F\u200B\u200C\u200E\u200F\u202A-\u202E\u2060-\u206F\u3164\uFE00-\uFE0D\uFEFF\uFFA0\uFFF0-\uFFFB\u{1BCA0}-\u{1BCA3}\u{1D173}-\u{1D17A}\u{E0000}-\u{E0FFF}]/gu;
// Numeric emoji ranges because Hermes lacks Unicode property escapes.
const isEmojiPart = (codePoint: number | undefined) =>
diff --git a/vite.config.ts b/vite.config.ts
index 1580dc88318..72e55509cfd 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -216,6 +216,7 @@ export default defineConfig({
perf: "warn",
},
rules: {
+ "eslint/no-control-regex": "off",
"typescript/no-this-alias": "off",
"unicorn/prefer-add-event-listener": "off",
"unicorn/prefer-string-starts-ends-with": "off",