Skip to content

feat(packages/sui-lint): fix RepositoryLinter node_modules ignore for pnpm#1991

Merged
tomasmax merged 3 commits into
masterfrom
fix/sui-lint-repository-pnpm-compat
Jun 18, 2026
Merged

feat(packages/sui-lint): fix RepositoryLinter node_modules ignore for pnpm#1991
tomasmax merged 3 commits into
masterfrom
fix/sui-lint-repository-pnpm-compat

Conversation

@tomasmax

@tomasmax tomasmax commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fix fast-glob ignore pattern in RepositoryLinter/Runner.js to properly exclude node_modules in pnpm-managed repos
  • Fix EISDIR crash in Match.js when directories have file-like extensions (e.g. Cypress screenshot dirs named *.js)

Problem

OOM crash (Runner.js)

sui-lint repository OOMs (crashes at 2GB heap) when running in repositories that use pnpm as package manager.

Root cause: fast-glob@3 treats the pattern 'node_modules' as matching only the literal top-level entry. It does NOT recursively prevent traversal into node_modules/.pnpm/ — pnpm's store directory that contains thousands of symlinked packages. The glob **/*.(j|t)s(x)? then matches files deep inside .pnpm/, reading all of them into memory until the process runs out of heap.

With the corrected pattern '**/node_modules/**', fast-glob skips any directory named node_modules at any depth.

EISDIR crash (Match.js)

Cypress creates screenshot directories named like .js files (e.g. cypress/screenshots/PTA/CategoryPicker.js). Match.create only checked isDirectory() when the path had no file extension, so these directories fell through to fs.readFileSync() which throws EISDIR.

Fix: Always check isDirectory() regardless of extension. Directory matches get raw = '' (empty string) instead of undefined, so rules that access match.raw.match(...) don't crash with a TypeError.

Results

Metric Before After
Execution time OOM crash (exit 134) ~3.8 seconds
Memory >4GB (exceeds heap limit) ~50MB
EISDIR errors Crash on repos with Cypress screenshots None

Tested on frontend-ma--web-app (pnpm 11, shamefully-hoist=true, ~10k source files).

Test plan

  • Run sui-lint repository on a pnpm monorepo — completes without OOM
  • Run sui-lint repository on a repo with Cypress screenshot directories — no EISDIR crash
  • Run sui-lint repository on an npm monorepo — verify same behavior as before (no regression)

🤖 Generated with Claude Code

… pnpm

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…positoryLinter

Cypress creates screenshot directories named like .js files (e.g.
cypress/screenshots/PTA/CategoryPicker.js). Match.create only checked
isDirectory when path had no extension, causing EISDIR crash on readFileSync.

Now checks isDirectory regardless of extension and returns an empty
string for raw content so rules that access match.raw don't crash.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ory handling

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tomasmax tomasmax merged commit c29c89e into master Jun 18, 2026
2 checks passed
@tomasmax tomasmax deleted the fix/sui-lint-repository-pnpm-compat branch June 18, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants