← Back to eslint/eslint

How to Deploy & Use eslint/eslint

ESLint Deployment and Usage Guide

Prerequisites

  • Node.js: ^20.19.0, ^22.13.0, or >=24 built with SSL support
  • npm: Version compatible with your Node.js installation
  • Operating System: Any OS that supports Node.js

Installation

Using npm

  1. Install ESLint globally (recommended for CLI usage):
npm install -g eslint
  1. Initialize ESLint configuration in your project:
npm init @eslint/config@latest
  1. Run ESLint on any file or directory:
npx eslint yourfile.js

Using pnpm

If you prefer using pnpm, create a .npmrc file with these settings:

auto-install-peers=true
node-linker=hoisted

This ensures compatibility with npm and reduces errors.

Configuration

Basic Configuration

Create an eslint.config.js file in your project root:

import { defineConfig } from "eslint/config";

export default defineConfig([
	{
		files: ["**/*.js", "**/*.cjs", "**/*.mjs"],
		rules: {
			"prefer-const": "warn",
			"no-constant-binary-expression": "error",
		},
	},
]);

Rule Configuration

Rules can be configured with these severity levels:

  • "off" or 0 - turn the rule off
  • "warn" or 1 - turn the rule on as a warning
  • "error" or 2 - turn the rule on as an error (exit code will be 1)

Supported ECMAScript Versions

ESLint supports ECMAScript 3, 5, and every year from 2015 up until the most recent stage 4 specification (default). Configure your desired ECMAScript syntax in the configuration file.

Build & Run

Local Development

  1. Install dependencies:
npm install
  1. Run ESLint on your codebase:
npx eslint .
  1. Auto-fix issues (if applicable):
npx eslint . --fix

Production Usage

ESLint is primarily a development tool and doesn't require a separate build process. Simply include it in your development dependencies:

npm install --save-dev eslint

Deployment

ESLint is a Node.js-based tool that runs locally during development. It doesn't require deployment to external platforms. However, you can integrate it into your CI/CD pipeline:

GitHub Actions

- name: ESLint Check
  run: npx eslint .

Other CI Platforms

Most CI platforms support running Node.js commands. Simply add npx eslint . to your build script.

Troubleshooting

Common Issues

  1. SSL Support Error:

    • Ensure your Node.js installation includes SSL support
    • Use an official Node.js distribution
  2. pnpm Compatibility Issues:

    • Add the recommended .npmrc settings
    • Use node-linker=hoisted for better compatibility
  3. Configuration Not Found:

    • Ensure eslint.config.js is in your project root
    • Verify the configuration syntax is correct

Getting Help

Version Support

ESLint provides ongoing support for the current version and six months of limited support for the previous version. For extended support, consider commercial options through Tidelift or HeroDevs.

Known Limitations

  • JSX Support: ESLint parses JSX syntax but doesn't recognize React-specific semantics. Use eslint-plugin-react for React projects.
  • Prettier Integration: ESLint and Prettier serve different purposes. Refer to Prettier's documentation for integration guidance.