or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

index.mddocs/

ESLint Config Node

ESLint 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.

Package Information

  • Package Name: eslint-config-node
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install --save-dev eslint-config-node
  • Main Entry: index.js (generated from index.yaml)

Core Imports

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']
};

Basic Usage

Installation:

npm install --save-dev eslint-config-node

Note: Depending on your npm version, you may need to install peer dependencies manually:

npm install --save-dev eslint eslint-config-esnext

After installation, add the configuration to your ESLint config file:

# .eslintrc.yaml
extends:
  - node

The configuration will automatically:

  • Enable Node.js environment and global variables
  • Extend the ESNext configuration
  • Apply Node.js-specific safety rules

For git hooks integration:

npm install --save-dev husky
# package.json
{
  "scripts": {
    "precommit": "eslint ."
  }
}

Architecture

ESLint Config Node is part of a comprehensive monorepo structure that provides multiple ESLint configurations:

Monorepo Structure:

  • Parent Package: @kunalgolani/eslint-config - The main monorepo package
  • eslint-config-node: Node.js-specific configuration (this package)
  • eslint-config-esnext: Modern JavaScript configuration (base dependency)
  • eslint-config-react-native: React Native configuration
  • eslint-config-recommended: General purpose configuration

Configuration Generation: The package uses a YAML-to-JSON build process for maintainability:

  1. Source: Rules are defined in index.yaml for readability
  2. Build Process: npm run prepare converts YAML to JSON using js-yaml
  3. Distribution: The index.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:

  • Consistent Rule Management: YAML files are easier to read and maintain
  • Shared Base Rules: Common rules from esnext are inherited and extended
  • Modular Approach: Each environment (Node.js, React Native, etc.) has focused configurations

Capabilities

Main Configuration

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-esnext
  • rules - Node.js-specific rule overrides

Rule Details:

  • no-path-concat: 2 (Error) - Prevents string concatenation with __dirname and __filename to avoid path separator issues
  • no-process-exit: 2 (Error) - Disallows direct use of process.exit() to ensure proper cleanup
  • no-sync: 1 (Warning) - Warns against synchronous methods to encourage asynchronous patterns

Usage:

extends:
  - node

Style Guide Configuration

A 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"]
}

Types

Environment Configuration

interface EnvironmentConfig {
  /** Enable Node.js environment and global variables */
  node: boolean;
}

Rule Configuration

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;
}

Configuration Structure

interface ESLintConfig {
  /** Environment settings */
  env?: EnvironmentConfig;
  /** Base configurations to extend */
  extends?: string | string[];
  /** Rule overrides */
  rules?: NodeRules & Record<string, any>;
}

Dependencies

This configuration includes the following dependencies:

Direct Dependencies:

  • eslint (^4.19.1) - Core ESLint engine
  • eslint-config-esnext (^3.0.2) - Base ESNext configuration that provides modern JavaScript rules

Peer Dependencies (must be installed separately):

  • eslint (^4.0.0) - Core ESLint engine (compatible versions)
  • eslint-config-esnext (^2.0.0) - Base ESNext configuration (minimum required version)

Dev Dependencies:

  • js-yaml (^3.12.0) - Used for build process to convert YAML configs to JSON

Philosophy and Design

This configuration follows an opinionated approach that:

  1. Safety First: Prevents common Node.js pitfalls and unsafe patterns
  2. Concise Code: Biases toward brevity while maintaining readability
  3. Superset Approach: Provides comprehensive rules that can be selectively overridden
  4. Node.js Focus: Specifically addresses server-side JavaScript development concerns

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.