Skip to content

Run local lint in typescript-eslint single-run mode, as in CI - #6556

Open
bram-atmire wants to merge 1 commit into
DSpace:mainfrom
bram-atmire:lint-single-run-typescript-eslint
Open

bram-atmire wants to merge 1 commit into
DSpace:mainfrom
bram-atmire:lint-single-run-typescript-eslint

Conversation

@bram-atmire

Copy link
Copy Markdown
Member

TL;DR & References

  • npm run lint locally uses about half the memory and is faster, the same as in CI. CI itself does not change.

Description

Locally, npm run lint can run out of memory with the 4 GB heap that CI uses. The reason is that typescript-eslint only uses its faster "single-run" mode when it detects CI (CI=true) or a direct eslint invocation, and ng lint locally is neither. This PR sets TSESTREE_SINGLE_RUN=true in the lint:nobuild script, so local lint runs the same way as in CI.

Instructions for Reviewers

typescript-eslint decides in inferSingleRun whether a run is a single run. If it is, it builds each TypeScript program once; otherwise it uses watch programs, which are meant for editors and use much more memory. GitHub Actions sets CI=true, so CI already uses single-run mode. A local ng lint does not match the detection, so it falls back to watch programs. TSESTREE_SINGLE_RUN=true is the documented way to force single-run mode.

Measured locally (macOS, Node 20.19), npm run lint:nobuild -- --quiet as in CI:

  • without this PR: out of memory with --max-old-space-size=4096; passes with 8 GB, 126 s, 6.5 GB peak memory
  • with this PR: passes with 4 GB, 95 s, 3.7 GB peak memory

List of changes in this PR:

  • package.json: lint:nobuild runs cross-env TSESTREE_SINGLE_RUN=true ng lint (npm run lint calls lint:nobuild). cross-env is already a dev dependency.
  • lint-fix is not changed on purpose: typescript-eslint does not use single-run mode with --fix, because fixes change files during the run.

How to test

  1. NODE_OPTIONS=--max-old-space-size=4096 npm run lint passes locally. On main it may run out of memory.
  2. CI lint passes as before.

AI Disclosure (REQUIRED)

Were AI tools used in the creation of this PR?

  • No (This PR does NOT include AI-generated or AI-assisted content that requires disclosure.)
  • Yes (This PR includes AI-generated or AI-assisted content that requires disclosure.)

Claude Code (claude-opus-5-5) found the cause in typescript-eslint's single-run detection, made the change and measured lint locally with and without it (memory and duration above). I reviewed the change and this description.

My human review didn't reveal any particular flaws.

Checklist

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR follows all coding best practices based on the Code Conventions Guide
  • My PR passes ESLint validation using npm run lint
  • My PR doesn't introduce circular dependencies (verified via npm run check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • My PR aligns with Accessibility guidelines if it makes changes to the user interface.
  • My PR uses i18n (internationalization) keys instead of hardcoded English text, to allow for translations.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

typescript-eslint only infers a single run when CI=true or when eslint is
invoked directly. A local "ng lint" matches neither, so typescript-eslint
falls back to watch programs, which need much more memory: locally lint
can run out of memory with the 4 GB heap used in CI. Set
TSESTREE_SINGLE_RUN=true for lint:nobuild, so local lint runs the same way
as CI. lint-fix is unchanged, because single-run mode is not used with
--fix.

Assisted-by: Claude Code [claude-opus-5-5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 🙋 Needs Reviewers Assigned

Development

Successfully merging this pull request may close these issues.

2 participants