fix(lint): clear 7 false-positive lint warnings
vp run check:lint reported 7 warnings, all false positives for a terminal UI library: - no-control-regex (×6): parsing keyboard escape sequences and stripping ANSI inherently requires regexes matching control chars (ESC, BEL). Disable the rule library-wide in vite.config.ts — it flags every such pattern and we already use \x1b/\u escapes (its own suggested form). Also drop the now- redundant (and misplaced — it sat one line above the regex) inline disable in sanitize-ansi.test.ts. - no-misused-spread (×1) at parse-keypress.ts:500: `[...s]` on a terminal escape sequence (ASCII control chars + digits, never user text), so the emoji-splitting concern doesn't apply. Suppressed in place with a comment explaining why, keeping the rule active elsewhere. check:lint now reports 0 warnings, 0 errors.
This commit is contained in:
@@ -497,6 +497,11 @@ export function parseKeypress(s: Uint8Array | string = ""): Keypress {
|
||||
key.meta = true;
|
||||
key.shift = /^[A-Z]$/.test(parts[1]!);
|
||||
} else if ((parts = fnKeyRe.exec(s))) {
|
||||
// `s` here is a terminal escape sequence (ASCII control chars + digits,
|
||||
// e.g. "\x1b[1;5A"), never user text, so it has no multi-codepoint
|
||||
// graphemes. Code-point spread is exactly what we want; the emoji-splitting
|
||||
// concern behind no-misused-spread does not apply.
|
||||
// eslint-disable-next-line no-misused-spread
|
||||
const segs = [...s];
|
||||
|
||||
if (segs[0] === "" && segs[1] === "") {
|
||||
|
||||
@@ -3,7 +3,6 @@ import { sanitizeAnsi } from "./sanitize-ansi.ts";
|
||||
|
||||
// Minimal ANSI-stripping helper for test assertions (avoids strip-ansi dep).
|
||||
function stripAnsi(s: string): string {
|
||||
// eslint-disable-next-line no-control-regex
|
||||
return s.replace(
|
||||
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:[:;][0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|[\u001b\u009d]\].*?(?:\u0007|\u001b\\|\u009c)|[\u001b\u0098][\s\S]*?(?:\u0007|\u001b\\|\u009c)|[\u0080-\u009f]/g,
|
||||
"",
|
||||
|
||||
+12
-1
@@ -5,7 +5,18 @@ export default defineConfig({
|
||||
"*": "vp check --fix",
|
||||
},
|
||||
fmt: {},
|
||||
lint: { options: { typeAware: true, typeCheck: false } },
|
||||
lint: {
|
||||
options: { typeAware: true, typeCheck: false },
|
||||
rules: {
|
||||
// This is a terminal UI library: parsing keyboard escape sequences and
|
||||
// stripping ANSI requires regexes that match control characters (ESC,
|
||||
// BEL, etc.) by design. no-control-regex flags every such pattern as a
|
||||
// false positive across the codebase, so disable it library-wide. We
|
||||
// already write them as \x1b / unicode escapes (the rule's own
|
||||
// suggested form), not raw bytes.
|
||||
"no-control-regex": "off",
|
||||
},
|
||||
},
|
||||
run: {
|
||||
cache: false,
|
||||
// `ci` is the parallel verification graph used by .github/workflows/ci.yml.
|
||||
|
||||
Reference in New Issue
Block a user