Skip to content

fix(no-sync): resolve full typed names for ignores#501

Merged
aladdin-add merged 3 commits intoeslint-community:masterfrom
patricktree:fix-broken-tests-in-main-branch
Jan 10, 2026
Merged

fix(no-sync): resolve full typed names for ignores#501
aladdin-add merged 3 commits intoeslint-community:masterfrom
patricktree:fix-broken-tests-in-main-branch

Conversation

@patricktree
Copy link

@patricktree patricktree commented Jan 8, 2026

@aladdin-add aladdin-add self-requested a review January 8, 2026 18:29
@patricktree patricktree marked this pull request as draft January 8, 2026 20:04
@aladdin-add
Copy link

@patricktree Have you found the cause of the issue? I tried it on my Windows + WSL (Ubuntu) setup, and no errors were reported during testing.

@patricktree
Copy link
Author

@patricktree Have you found the cause of the issue? I tried it on my Windows + WSL (Ubuntu) setup, and no errors were reported during testing.

Still investigating it.
On my Mac OS it also doesn't report errors - its only in CI...

@patricktree patricktree force-pushed the fix-broken-tests-in-main-branch branch from b0970e0 to aacd206 Compare January 10, 2026 14:35
@patricktree patricktree force-pushed the fix-broken-tests-in-main-branch branch from aacd206 to 92655f8 Compare January 10, 2026 14:36
@patricktree
Copy link
Author

patricktree commented Jan 10, 2026

I found out that CI=true is causing the issue.

You can locally run:

CI=true npm run -s test:tests
# or:
CI=true npm exec _mocha -- --reporter progress --timeout 4000 tests/lib/rules/no-sync.js

...and get the failures too.

I pushed a change which sets CI=false when running the tests, and that works - no failures anymore.
That's a workaround, the question is what the root cause is?

@patricktree
Copy link
Author

I've let Claude Code loose on the issue, it says:

Found the root cause!

  Summary

  When CI=true:
  1. TypeScript-eslint detects this as a "single run" scenario (see node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/inferSingleRun.js:50)
  2. In singleRun mode, after the first parse of a file path (file.ts), all subsequent parses use createIsolatedProgram instead of the project service
  3. createIsolatedProgram creates a minimal isolated program with noResolve: true and no access to TypeScript lib types (DOM, etc.)
  4. Tests relying on type info (like checking if replaceSync comes from CSSStyleSheet in the DOM lib) fail because the isolated program has no such type information

  When CI=false:
  - No isolated programs are created - always uses project service
  - All type info from lib.d.ts (DOM types like CSSStyleSheet) is available
  - Tests pass

  Evidence: With CI=true, multiple isolated programs are created for file.ts:
  Getting isolated program in TS mode for: .../tests/fixtures/no-sync/base/file.ts
  Getting isolated program in TS mode for: .../tests/fixtures/no-sync/base/file.ts
  ...
  3 failing

  With CI=false: No isolated programs created, all tests pass.

  Root issue: All TypeScript tests in no-sync/base share the same filename (file.ts). After the first test, the singleRun optimization kicks in and uses isolated programs without type context.

typescript-eslint's singleRun optimization (triggered by CI=true) uses
isolated programs without type info after the first parse of a filename.
This caused tests relying on type info (e.g., CSSStyleSheet.replaceSync)
to fail when multiple tests shared the same file.ts filename.

- Generate unique filenames (file-1.ts, file-2.ts, etc.) per test case
- Use allowDefaultProject for virtual test files instead of blocking them
- Remove CI=false workaround from GitHub Actions workflow

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@patricktree
Copy link
Author

I've let CC fix it:

  Summary of Changes

  tests/test-helpers.js - Two changes:

  1. Unique filenames per test - Added counter to generate file-1.ts, file-2.ts, etc. instead of always using file.ts. This prevents typescript-eslint's singleRun optimization from reusing isolated programs without type info.
  2. Use allowDefaultProject - Replaced maximumDefaultProjectFileMatchCount: 0 with allowDefaultProject: ["file-*.ts"] so the virtual test files can be handled by the default project since they don't exist on disk.

  .github/workflows/CI.yml - Removed the CI=false workaround since it's no longer needed.

see a75eb34

@patricktree patricktree marked this pull request as ready for review January 10, 2026 15:23
Copy link

@aladdin-add aladdin-add left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! ❤️

@aladdin-add aladdin-add merged commit 047301a into eslint-community:master Jan 10, 2026
29 checks passed
@patricktree patricktree deleted the fix-broken-tests-in-main-branch branch January 10, 2026 15: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