npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-worker-pool

v0.1.4

Published

High-performance ESLint worker pool for programmatic parallel linting in Node.js applications

Readme

npm version npm downloads license

High-performance ESLint worker pool for programmatic parallel linting

Features

  • 👷 Put Workers to work: Run ESLint in worker threads to keep main thread responsive
  • Parallel Processing: Process multiple files simultaneously across worker threads
  • ⚖️ Automatic Load Balancing: Tasks distributed across available workers
  • 🧹 Explicit Resource Management: Modern using/await using syntax for automatic cleanup

Why ESLint Worker Pool?

When running ESLint programmatically, it blocks the main thread and processes files sequentially, causing performance bottlenecks and freezing applications during linting. This package moves ESLint to dedicated worker threads, enabling parallel processing across multiple CPU cores while keeping your main thread responsive.

This package itself was built for Nuxt Audit which needed to run potentially thousands of HTML files in parallel without blocking the main thread.

Installation

# npm
npm install eslint-worker-pool

# yarn
yarn add eslint-worker-pool

# pnpm
pnpm add eslint-worker-pool

Quick Start

import { createESLintWorkerPool } from 'eslint-worker-pool'

// Using modern Explicit Resource Management for automatic cleanup
await using pool = createESLintWorkerPool({
  cache: true,
  fix: false,
  overrideConfig: {
    rules: {
      'no-console': 'warn',
      'semi': ['error', 'never']
    }
  }
})

// Lint multiple files in parallel
const results = await pool.lintFilesParallel([
  'src/file1.js',
  'src/file2.js',
  'src/file3.js'
])

console.log('Linting complete:', results)
// Pool automatically terminated when scope ends - no manual cleanup needed!

API

createESLintWorkerPool(options?, config?)

Creates a worker pool for parallel ESLint processing.

import { createESLintWorkerPool } from 'eslint-worker-pool'

await using pool = createESLintWorkerPool(
  // ESLint options
  {
    cache: true,
    fix: false,
    overrideConfig: {
      rules: { 'no-console': 'error' }
    }
  },
  // Pool configuration
  {
    poolSize: 4, // Number of workers (default: CPU count)
    timeouts: { enableTimeouts: false }
  }
)
// Pool automatically cleaned up when scope ends

Pool Methods

lintFiles(files, options?)

Lint files using the worker pool.

// Single file
const result = await pool.lintFiles('src/app.js')

// Multiple files (processed by one worker)
const results1 = await pool.lintFiles(['src/a.js', 'src/b.js'])

// With custom options
const results2 = await pool.lintFiles('src/app.js', { fix: true })

lintText(text, filePath, options?)

Lint text content directly.

const results = await pool.lintText(
  'console.log("hello")',
  'virtual.js'
)

lintFilesParallel(files, options?)

Process multiple files in parallel across all workers.

const results = await pool.lintFilesParallel([
  'src/file1.js',
  'src/file2.js',
  'src/file3.js',
  'src/file4.js'
])
// Each file processed by different worker when possible

getStats()

Get pool statistics.

const stats = pool.getStats()
console.log({
  poolSize: stats.poolSize,
  activeWorkers: stats.activeWorkers,
  queuedTasks: stats.queuedTasks,
  totalWorkers: stats.totalWorkers,
  terminated: stats.terminated
})

drain()

Wait for all pending tasks to complete.

await pool.drain() // Wait for queue to empty

terminate()

Shut down all workers. Always call this when done.

await pool.terminate()

Real-World Examples

Express.js API Endpoint

import { createESLintWorkerPool } from 'eslint-worker-pool'
import express from 'express'

const app = express()

// Create pool that will be automatically cleaned up
await using pool = createESLintWorkerPool({ cache: true })

app.post('/lint', async (req, res) => {
  try {
    const { code, filename } = req.body
    const results = await pool.lintText(code, filename)
    res.json({ success: true, results })
  }
  catch (error) {
    res.status(500).json({ success: false, error: error.message })
  }
})

// Pool automatically terminated when application shuts down

Build Tool Integration

import { createESLintWorkerPool } from 'eslint-worker-pool'
import { glob } from 'glob'

async function lintProject() {
  const files = await glob('src/**/*.{js,ts}')

  await using pool = createESLintWorkerPool({
    cache: true,
    fix: process.env.NODE_ENV === 'development'
  })

  console.log(`Linting ${files.length} files...`)
  const results = await pool.lintFilesParallel(files)

  const errors = results.flat().filter(r =>
    r.messages.some(m => m.severity === 2)
  )

  if (errors.length > 0) {
    console.error(`Found ${errors.length} files with errors`)
    process.exit(1)
  }

  console.log('✅ All files passed linting')
  // Pool automatically terminated when function ends
}

lintProject().catch(console.error)

File Watcher

import { watch } from 'chokidar'
import { createESLintWorkerPool } from 'eslint-worker-pool'

// Global pool for long-running watcher
await using pool = createESLintWorkerPool({ cache: true, fix: true })

watch('src/**/*.js').on('change', async (filePath) => {
  try {
    console.log(`Linting ${filePath}...`)
    const results = await pool.lintFiles(filePath)

    const hasErrors = results[0].messages.some(m => m.severity === 2)
    if (hasErrors) {
      console.error(`❌ ${filePath} has errors`)
    }
    else {
      console.log(`✅ ${filePath} is clean`)
    }
  }
  catch (error) {
    console.error(`Error linting ${filePath}:`, error.message)
  }
})

// Pool automatically terminated when process ends

Error Handling

The worker pool includes comprehensive error types for better debugging:

import {
  createESLintWorkerPool,
  PoolTerminatedError,
  ValidationError,
  WorkerTimeoutError
} from 'eslint-worker-pool'

await using pool = createESLintWorkerPool()

try {
  await pool.lintFiles('../invalid-path')
}
catch (error) {
  if (error instanceof ValidationError) {
    console.error('Invalid input:', error.message)
  }
  else if (error instanceof PoolTerminatedError) {
    console.error('Pool was terminated')
  }
  else if (error instanceof WorkerTimeoutError) {
    console.error('Worker timed out')
  }
}
// Pool automatically cleaned up even if errors occur

Resource Management

This package supports modern Explicit Resource Management (using/await using) for automatic cleanup, eliminating the need for manual terminate() calls.

✅ Recommended: Using await using (Async)

For most use cases, use await using for automatic async cleanup:

await using pool = createESLintWorkerPool()
// Pool automatically terminated when scope ends

Alternative: Using using (Sync)

For synchronous scopes, use using (though less ideal for worker cleanup):

using pool = createESLintWorkerPool()
// Pool cleanup triggered synchronously when scope ends

Legacy: Manual Cleanup

Still supported but not recommended:

const pool = createESLintWorkerPool()
try {
  // Use pool...
}
finally {
  await pool.terminate() // Manual cleanup required
}

License

MIT