From 70518dc58ac38b442fcf35f7559d0613b5c5f35f Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Mon, 4 May 2026 10:59:54 -0400 Subject: [PATCH 1/2] fix: prevent doctest false-positive on function declarations and remove stale ESLint disable directive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `RE_ANNOTATION` regex in the doctest rule used `[^;]*` which could span across `function noop() { // Do nothing... }` (no semicolon in body), then greedily match the first `console.log(...);\n// =>` annotation, capturing `function` as group 1. Since `scope['function']` is `undefined`, the rule incorrectly reported a mismatch for every annotation in the file. Adding `(?!function\b)` negative lookahead prevents the regex from starting a match at a bare `function` keyword. Identifiers that merely begin with `function` (e.g. `functionName`) are not affected because `\b` requires a word boundary. Also removes the stale `// eslint-disable-line no-buffer-constructor` in `utils/constructor-name/examples/index.js` — the rule is not configured in stdlib's ESLint setup and the directive triggers an unknown-rule warning. --- .../@stdlib/_tools/eslint/rules/doctest/lib/main.js | 4 ++-- .../@stdlib/utils/constructor-name/examples/index.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/_tools/eslint/rules/doctest/lib/main.js b/lib/node_modules/@stdlib/_tools/eslint/rules/doctest/lib/main.js index 98e629f1b119..23f9f332c932 100644 --- a/lib/node_modules/@stdlib/_tools/eslint/rules/doctest/lib/main.js +++ b/lib/node_modules/@stdlib/_tools/eslint/rules/doctest/lib/main.js @@ -48,9 +48,9 @@ var ROOT_DIR = rootDir(); var RE_JSDOC = /\/\*\*[\s\S]+?\*\//g; var RE_ESLINT_INLINE = / ?\/\/ eslint-disable-(?:next-)?line[^\n]*\n/g; var RE_NEWLINE = /\r?\n/g; -var RE_ANNOTATION = /(?:\n|^)(?:var|let|const)? ?([a-zA-Z0-9._]+) ?=?[^;]*;\n\/\/ ?(returns|([A-Za-z][A-Za-z_0-9]*)? ?=>|throws) {0,1}([\s\S]*?)(\n|$)/g; +var RE_ANNOTATION = /(?:\n|^)(?:var|let|const)? ?(?!function\b)([a-zA-Z0-9._]+) ?=?[^;]*;\n\/\/ ?(returns|([A-Za-z][A-Za-z_0-9]*)? ?=>|throws) {0,1}([\s\S]*?)(\n|$)/g; var RE_CONSOLE = /console\.(?:dir|error|log)/; -var NODE_SHEBANG = /#!\/usr\/bin\/env node/; +var NODE_SHEBANG = /#!/usr/bin/env node/; var rule; diff --git a/lib/node_modules/@stdlib/utils/constructor-name/examples/index.js b/lib/node_modules/@stdlib/utils/constructor-name/examples/index.js index 85b4a4164250..14c8f3aedda7 100644 --- a/lib/node_modules/@stdlib/utils/constructor-name/examples/index.js +++ b/lib/node_modules/@stdlib/utils/constructor-name/examples/index.js @@ -148,7 +148,7 @@ console.log( constructorName( new Float64Array() ) ); console.log( constructorName( new ArrayBuffer() ) ); // => 'ArrayBuffer' -console.log( constructorName( new Buffer( 'beep' ) ) ); // eslint-disable-line no-buffer-constructor +console.log( constructorName( new Buffer( 'beep' ) ) ); // => 'Buffer' console.log( constructorName( Math ) ); From 15fce810ec8caf76dc808c368cdcca26c8154990 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Mon, 4 May 2026 11:04:16 -0400 Subject: [PATCH 2/2] fix: correct NODE_SHEBANG regex escaping in doctest rule Forward slashes inside the regex literal must be escaped as \/ to avoid prematurely terminating the regex delimiter. The prior push omitted the backslashes, producing a syntax error that broke module loading. --- .../@stdlib/_tools/eslint/rules/doctest/lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/_tools/eslint/rules/doctest/lib/main.js b/lib/node_modules/@stdlib/_tools/eslint/rules/doctest/lib/main.js index 23f9f332c932..ca4b2234a5dd 100644 --- a/lib/node_modules/@stdlib/_tools/eslint/rules/doctest/lib/main.js +++ b/lib/node_modules/@stdlib/_tools/eslint/rules/doctest/lib/main.js @@ -50,7 +50,7 @@ var RE_ESLINT_INLINE = / ?\/\/ eslint-disable-(?:next-)?line[^\n]*\n/g; var RE_NEWLINE = /\r?\n/g; var RE_ANNOTATION = /(?:\n|^)(?:var|let|const)? ?(?!function\b)([a-zA-Z0-9._]+) ?=?[^;]*;\n\/\/ ?(returns|([A-Za-z][A-Za-z_0-9]*)? ?=>|throws) {0,1}([\s\S]*?)(\n|$)/g; var RE_CONSOLE = /console\.(?:dir|error|log)/; -var NODE_SHEBANG = /#!/usr/bin/env node/; +var NODE_SHEBANG = /#!\/usr\/bin\/env node/; var rule;