From 3fdf2f7aa82bcfdcd583ec0ed9d0b7d1080c0b01 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sun, 3 May 2026 10:44:27 -0400 Subject: [PATCH] fix: stop doctest regex overrun in constructor-name example The CI JavaScript lint job on develop has been failing since 2026-05-01 with two errors in utils/constructor-name/examples/index.js: 39:1 error Displayed return value is `'String'`, but expected `undefined` instead stdlib/doctest 151:57 error Unused eslint-disable directive (no problems were reported from 'no-buffer-constructor') Error 1: The stdlib/doctest rule's RE_ANNOTATION regex contains a greedy [^;]* segment that matches newlines. Starting at `\nfunction noop() {`, the regex spans across the comment-only body (no `;`) to `console.log( constructorName( 'a' ) );`, falsely associating `// => 'String'` with the function expression, which evaluates to `undefined` in the VM sandbox. Adding `return void 0;` inside noop() places a semicolon in the body, causing the greedy match to terminate there. The following `\n}` does not match `\n//`, so the false association attempt fails and the regex correctly matches the console.log call on the next attempt. Error 2: `no-buffer-constructor` is not configured in any of the project's ESLint rule files; the inline disable directive was stale. Failing run: https://github.com/stdlib-js/stdlib/actions/runs/25195861572 --- .../@stdlib/utils/constructor-name/examples/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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..1c1da6d6ed24 100644 --- a/lib/node_modules/@stdlib/utils/constructor-name/examples/index.js +++ b/lib/node_modules/@stdlib/utils/constructor-name/examples/index.js @@ -39,6 +39,7 @@ var constructorName = require( './../lib' ); function noop() { // Do nothing... + return void 0; } console.log( constructorName( 'a' ) ); @@ -148,7 +149,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 ) );