node
> ESLint flat config for Node.js with TypeScript. Extends @jmlweb/eslint-config-base with eslint-plugin-n rules and Node.js globals.
> ๐ง Maintenance mode: only dependency and security updates, no new rules. For new projects use @jmlweb/oxlint-config-node. To move an existing project, see the migration guide.
โจ Features
Section titled โโจ Featuresโ- ๐ข Node.js rules:
eslint-plugin-nrecommended plus stricter module, process and API rules - ๐ Node.js globals:
process,Buffer,__dirnameand friends - ๐ Strict TypeScript: everything from
@jmlweb/eslint-config-base - ๐ฆ
node:protocol: built-in modules must use thenode:prefix - ๐จ Prettier compatible: disables rules that conflict with Prettier
๐ฆ Installation
Section titled โ๐ฆ Installationโnpm install --save-dev @jmlweb/eslint-config-node @jmlweb/eslint-config-base eslint @eslint/js typescript-eslint eslint-config-prettier eslint-plugin-simple-import-sort eslint-plugin-n globals> ๐ก Upgrading? See the Migration Guide.
๐ Quick Start
Section titled โ๐ Quick Startโimport nodeConfig from '@jmlweb/eslint-config-node';
export default [ ...nodeConfig, // Project-specific overrides];๐ก Examples
Section titled โ๐ก ExamplesโTest overrides and ignores
Section titled โTest overrides and ignoresโimport nodeConfig from '@jmlweb/eslint-config-node';
export default [ ...nodeConfig, { files: ['**/*.test.ts', '**/*.spec.ts'], rules: { '@typescript-eslint/no-explicit-any': 'off', 'n/no-process-exit': 'off', }, }, { ignores: ['dist/', 'build/', 'node_modules/'], },];Soften Node.js rules
Section titled โSoften Node.js rulesโimport nodeConfig from '@jmlweb/eslint-config-node';
export default [ ...nodeConfig, { files: ['**/*.ts', '**/*.js'], rules: { 'n/no-process-exit': 'warn', 'n/no-unpublished-import': 'off', }, },];๐ Configuration Details
Section titled โ๐ Configuration DetailsโApplied to **/*.ts, **/*.js, **/*.mjs and **/*.cjs, with globals.node enabled.
Included
Section titled โIncludedโ- โ
Everything from
@jmlweb/eslint-config-base - โ
eslint-plugin-nflat/recommended - โ Import and export sorting, Prettier conflict resolution
Key rules
Section titled โKey rulesโ| Rule | Level |
|---|---|
n/no-process-exit, n/process-exit-as-throw |
error |
n/no-missing-import, n/no-missing-require |
error |
n/no-unpublished-import, n/no-unpublished-require |
error |
n/no-extraneous-import, n/no-extraneous-require |
error |
n/no-deprecated-api |
warn |
n/no-callback-literal, n/no-new-require, n/no-path-concat |
error |
n/prefer-global/* (buffer, console, process, url, url-search-params) |
error (always) |
n/prefer-promises/dns, n/prefer-promises/fs |
error |
n/prefer-node-protocol |
error |
๐ Import Sorting
Section titled โ๐ Import SortingโImports are sorted and type-only imports are enforced.
Before:
import { Component } from './component';import express from 'express';import fs from 'node:fs';import { User } from './types';After eslint --fix:
import express from 'express';import fs from 'node:fs';import { type User } from './types';import { Component } from './component';๐ฏ When to Use
Section titled โ๐ฏ When to Useโ- โ Node.js libraries, CLIs and services written in TypeScript
- โ Catching missing or unpublished imports and deprecated APIs
- โ Strict type-aware linting for backend code
For non-Node.js TypeScript use @jmlweb/eslint-config-base. For new projects prefer @jmlweb/oxlint-config-node.
๐ง Extending the Configuration
Section titled โ๐ง Extending the ConfigurationโSpread the config, then add objects after it. Later entries win.
import nodeConfig from '@jmlweb/eslint-config-node';
export default [ ...nodeConfig, { files: ['scripts/**/*.js'], rules: { 'n/no-process-exit': 'off', }, },];๐ Usage with Scripts
Section titled โ๐ Usage with Scriptsโ{ "scripts": { "lint": "eslint .", "lint:fix": "eslint . --fix" }}npm run lint๐ Requirements
Section titled โ๐ Requirementsโ- Node.js >= 22.12.0
- ESLint ^9.0.0 || ^10.0.0 (flat config)
- TypeScript project with a
tsconfig.json(versions supported by typescript-eslint 8)
๐ฆ Peer Dependencies
Section titled โ๐ฆ Peer Dependenciesโeslint(^9.0.0 || ^10.0.0)@eslint/js(^9.0.0 || ^10.0.0)typescript-eslint(^8.0.0)eslint-config-prettier(^9.1.0 || ^10.0.0)eslint-plugin-n(^17.0.0 || ^18.0.0)eslint-plugin-simple-import-sort(^12.0.0 || ^13.0.0 || ^14.0.0)globals(^15.0.0 || ^16.0.0 || ^17.0.0)@jmlweb/eslint-config-base(^3.0.3)
๐ Related Packages
Section titled โ๐ Related Packagesโ@jmlweb/eslint-config-base: TypeScript config (extended by this package)@jmlweb/oxlint-config-node: Oxlint equivalent, recommended for new projects@jmlweb/tsconfig-node: TypeScript config for Node.js@jmlweb/prettier-config-base: Prettier config (maintenance mode)
๐ Migration Guide
Section titled โ๐ Migration Guideโ2.x to 3.0
Section titled โ2.x to 3.0โNode.js 18 and 20 are end-of-life. Node.js >= 22.12.0 is now required: it is the first Node.js 22 release that can require() ES modules without a flag, which the CommonJS build needs to load ESM-only plugins. Peer ranges were also widened (eslint-plugin-n 18, eslint-plugin-simple-import-sort 13 and 14).
- Upgrade Node.js to 22.12.0 or later.
- Update the package:
npm install --save-dev @jmlweb/eslint-config-node@latest.
See the Changelog.
๐ License
Section titled โ๐ LicenseโMIT