@pathtx/eslint-dispatcher
v0.0.3
Published
A caching, parallel-batching wrapper around ESLint's flat config CLI. It walks a directory itself, splits the matching files into size-bounded batches, runs `eslint --format json` on each batch across a worker pool, and caches per-file results (content-ad
Readme
@pathtx/eslint-dispatcher
A caching, parallel-batching wrapper around ESLint's flat config CLI. It walks a directory
itself, splits the matching files into size-bounded batches, runs eslint --format json on
each batch across a worker pool, and caches per-file results (content-addressed, keyed on
file content + config + ESLint version) so a re-run only re-lints what actually changed.
Requirements
- Node.js with
pnpmavailable onPATH(batches are run viapnpm exec eslint) - A git repository — the cache root and target resolution are relative to
git rev-parse --show-toplevel - An
eslint.config.{js,mjs,ts,mts}at the repo root
Install
pnpm add -D @pathtx/eslint-dispatcherCLI usage
eslint-dispatcher [path] [...eslint args]path— file or directory to lint, defaults to.- Any remaining arguments are forwarded to ESLint, with two exceptions handled by the
dispatcher itself:
--fix— also bypasses the result cache for files that previously had errors--jobs/-j <n>— number of batches to run concurrently (default5)
--format/-fis stripped if passed — output is always requested as JSON internally so results can be cached and re-printed per file
eslint-dispatcher src --fix
eslint-dispatcher . --jobs 8Exit code is 1 if any linted file (cached or fresh) has errors, 0 otherwise.
Library usage
import { eslint, quickbuild } from '@pathtx/eslint-dispatcher';
await eslint.run('src', ['--fix']);
const mod = await quickbuild.quickBundle('./some-script.ts', []);eslint.run(targetPath, rawEslintArgs)— the same entry point the CLI callsquickbuild.quickBundle(entryFile, otherFiles, options?, extraPrefix?)— bundles andimport()s a TypeScript/JS entry point on demand via esbuild, caching the build under.quickbuild/quickbuild.quickBundleModule(moduleName, options?, returnDefault?)— same, but for re-exporting an installed module through esbuild
Caching
Both caches live under <repo-root>/.eslintcache/:
config/— the resolved set of ignore globs fromeslint.config.*, keyed by config file hashresults/— per-file lint output, keyed by config hash, ESLint version, effective CLI args, file path, and file content
Result cache entries older than 14 days are pruned at the end of each run. Delete
.eslintcache/ to force a full re-lint.
Development
pnpm install
pnpm run lint # lint this repo with itself
pnpm run typecheck # tsc --noEmit
pnpm run build # bundle bin/cli.ts + src/index.ts with esbuild, emit .d.ts files
pnpm run prettier # format src/* and package.jsonpnpm run build produces:
dist/cli.mjs,dist/index.mjs— esbuild bundles (ESM, Node platform, source maps,node_modulesdependencies left external)dist/types/—.d.tsdeclarations for both entry points, emitted bytscviatsconfig.build.json
