Fix node-module-error plugin matching identifiers in multi-line comments#1554
Fix node-module-error plugin matching identifiers in multi-line comments#1554
Conversation
The findIdentifierUsage function only stripped single-line comments and same-line block comments, but didn't track multi-line block comment state. Lines inside JSDoc/block comments (e.g. ` * ... Writable stream`) passed through unstripped, causing the plugin to point at comments instead of actual code usage. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: aa319fe The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🧪 E2E Test Results❌ Some tests failed Summary
❌ Failed Tests▲ Vercel Production (1 failed)nextjs-webpack (1 failed):
🌍 Community Worlds (60 failed)mongodb (3 failed):
redis (2 failed):
turso (55 failed):
Details by Category❌ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
❌ 🌍 Community Worlds
✅ 📋 Other
❌ Some E2E test jobs failed:
Check the workflow run for details. |
📊 Benchmark Results
workflow with no steps💻 Local Development
▲ Production (Vercel)
workflow with 1 step💻 Local Development
▲ Production (Vercel)
workflow with 10 sequential steps💻 Local Development
▲ Production (Vercel)
workflow with 25 sequential steps💻 Local Development
▲ Production (Vercel)
workflow with 50 sequential steps💻 Local Development
▲ Production (Vercel)
Promise.all with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
Promise.all with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
Promise.all with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
Promise.race with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
Promise.race with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
Promise.race with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
workflow with 10 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
workflow with 25 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
workflow with 50 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
workflow with 10 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
workflow with 25 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
workflow with 50 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
Stream Benchmarks (includes TTFB metrics)workflow with stream💻 Local Development
▲ Production (Vercel)
stream pipeline with 5 transform steps (1MB)💻 Local Development
▲ Production (Vercel)
10 parallel streams (1MB each)💻 Local Development
▲ Production (Vercel)
fan-out fan-in 10 streams (1MB each)💻 Local Development
▲ Production (Vercel)
SummaryFastest Framework by WorldWinner determined by most benchmark wins
Fastest World by FrameworkWinner determined by most benchmark wins
Column Definitions
Worlds:
❌ Some benchmark jobs failed:
Check the workflow run for details. |
There was a problem hiding this comment.
Pull request overview
This PR updates the workflow-node-module-error esbuild plugin’s identifier usage detection so that references inside multi-line block comments (including JSDoc) are ignored, improving the accuracy of reported violation locations.
Changes:
- Reworked
findIdentifierUsageto track and skip multi-line block comments across lines while preserving column alignment via space replacement. - Added tests covering JSDoc multi-line comments and single-line
/* ... */comments. - Added a changeset to publish the fix as a patch for
@workflow/builders.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/builders/src/node-module-esbuild-plugin.ts | Implements stateful block-comment skipping in findIdentifierUsage and preserves original lineText in returned locations. |
| packages/builders/src/node-module-esbuild-plugin.test.ts | Adds regression tests ensuring violations point to real code usage instead of block/JSDoc comments. |
| .changeset/fix-multiline-comment-skip.md | Declares a patch release note for the plugin location fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Handle multi-line block comments (including JSDoc) | ||
| if (inBlockComment) { | ||
| const endIdx = line.indexOf('*/'); | ||
| if (endIdx === -1) { | ||
| // Entire line is inside a block comment | ||
| continue; | ||
| } | ||
| // Replace everything up to and including */ with spaces | ||
| line = ' '.repeat(endIdx + 2) + line.slice(endIdx + 2); | ||
| inBlockComment = false; | ||
| } | ||
|
|
||
| // Skip comments (both // and /* */ style) | ||
| const withoutComments = line | ||
| .replace(/\/\*[\s\S]*?\*\//g, '') | ||
| .replace(/\/\/.*$/, ''); | ||
| // Remove single-line block comments and detect block comment starts | ||
| let processed = ''; | ||
| let j = 0; | ||
| while (j < line.length) { | ||
| if (line[j] === '/' && line[j + 1] === '/') { | ||
| // Rest of line is a comment | ||
| processed += ' '.repeat(line.length - j); | ||
| break; | ||
| } | ||
| if (line[j] === '/' && line[j + 1] === '*') { | ||
| const endIdx = line.indexOf('*/', j + 2); | ||
| if (endIdx !== -1) { | ||
| // Inline block comment - replace with spaces | ||
| const len = endIdx + 2 - j; | ||
| processed += ' '.repeat(len); | ||
| j = endIdx + 2; | ||
| } else { | ||
| // Block comment starts here, continues on next lines | ||
| processed += ' '.repeat(line.length - j); | ||
| inBlockComment = true; | ||
| break; | ||
| } | ||
| } else { | ||
| processed += line[j]; | ||
| j += 1; | ||
| } | ||
| } |
There was a problem hiding this comment.
findIdentifierUsage's comment scanning runs before string-literal stripping and doesn't track string state. If a line contains /* inside a string literal without a matching */ (e.g. const s = "/*";), the loop will incorrectly enter inBlockComment and then skip all subsequent lines until a */ is found (potentially never), causing real identifier usages later in the file to be missed and the violation to go unreported. Consider stripping/replacing strings with spaces before detecting ////* tokens, or extending the scanner to ignore comment delimiters while inside '"/` strings; adding a regression test for this case would help.
There was a problem hiding this comment.
Fixed — moved string literal stripping before the comment scanner so /* inside strings no longer triggers block comment mode. Added a regression test for const pattern = "/* Writable */";.
Move string stripping before comment detection so that comment delimiters inside string literals (e.g. `const s = "/*"`) don't incorrectly trigger block comment mode. Adds regression test. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
findIdentifierUsagein theworkflow-node-module-erroresbuild plugin to properly skip multi-line block comments (including JSDoc)/** ... */blocks didn't get stripped because the old regex only handled same-line/* ... */— causing the plugin to point error locations at comment text instead of actual code usageTest plan
🤖 Generated with Claude Code