Pluggable ESLint configuration for Node.js that extends ESNext with Node.js-specific safety checks and best practices
npx @tessl/cli install tessl/npm-eslint-config-node@3.0.0ESLint Config Node is a pluggable ESLint configuration preset specifically tailored for Node.js development. It extends the ESNext configuration and adds Node.js-specific safety checks and best practices, emphasizing code concision while preventing common Node.js pitfalls.
npm install --save-dev eslint-config-nodeindex.js (generated from index.yaml)This package is used as an ESLint configuration preset rather than being imported directly into code:
# .eslintrc.yaml
extends:
- node# .eslintrc.json
{
"extends": ["node"]
}// .eslintrc.js
module.exports = {
extends: ['node']
};Installation:
npm install --save-dev eslint-config-nodeNote: Depending on your npm version, you may need to install peer dependencies manually:
npm install --save-dev eslint eslint-config-esnextAfter installation, add the configuration to your ESLint config file:
# .eslintrc.yaml
extends:
- nodeThe configuration will automatically:
For git hooks integration:
npm install --save-dev husky# package.json
{
"scripts": {
"precommit": "eslint ."
}
}ESLint Config Node is part of a comprehensive monorepo structure that provides multiple ESLint configurations:
Monorepo Structure:
@kunalgolani/eslint-config - The main monorepo packageConfiguration Generation: The package uses a YAML-to-JSON build process for maintainability:
index.yaml for readabilitynpm run prepare converts YAML to JSON using js-yamlindex.json file serves as the main entry point ("main": "index.js")Style Guide Variant:
Includes a /style-guide subpackage that extends esnext/style-guide with Node.js considerations.
This architecture allows for:
The primary ESLint configuration for Node.js projects that provides comprehensive linting rules.
{
"env": {
"node": true
},
"extends": "esnext",
"rules": {
"no-path-concat": 2,
"no-process-exit": 2,
"no-sync": 1
}
}Configuration Properties:
env.node: true - Enables Node.js environment and global variables (process, Buffer, __dirname, etc.)extends: "esnext" - Inherits all rules from eslint-config-esnextrules - Node.js-specific rule overridesRule Details:
no-path-concat: 2 (Error) - Prevents string concatenation with __dirname and __filename to avoid path separator issuesno-process-exit: 2 (Error) - Disallows direct use of process.exit() to ensure proper cleanupno-sync: 1 (Warning) - Warns against synchronous methods to encourage asynchronous patternsUsage:
extends:
- nodeA style guide variant that extends the ESNext style guide with Node.js considerations.
{
"extends": "esnext/style-guide"
}This configuration inherits styling rules from the ESNext style guide and applies them to Node.js projects.
Usage:
extends:
- node/style-guide{
"extends": ["node/style-guide"]
}interface EnvironmentConfig {
/** Enable Node.js environment and global variables */
node: boolean;
}interface NodeRules {
/** Disallow string concatenation with __dirname and __filename */
"no-path-concat": 0 | 1 | 2;
/** Disallow the use of process.exit() */
"no-process-exit": 0 | 1 | 2;
/** Disallow synchronous methods */
"no-sync": 0 | 1 | 2;
}interface ESLintConfig {
/** Environment settings */
env?: EnvironmentConfig;
/** Base configurations to extend */
extends?: string | string[];
/** Rule overrides */
rules?: NodeRules & Record<string, any>;
}This configuration includes the following dependencies:
Direct Dependencies:
Peer Dependencies (must be installed separately):
Dev Dependencies:
This configuration follows an opinionated approach that:
The configuration is designed as a foundation that teams can build upon, overriding rules as needed for their specific requirements while maintaining consistent baseline safety and style standards.