ESLint Deployment and Usage Guide
Prerequisites
- Node.js:
^20.19.0,^22.13.0, or>=24built with SSL support - npm: Version compatible with your Node.js installation
- Operating System: Any OS that supports Node.js
Installation
Using npm
- Install ESLint globally (recommended for CLI usage):
npm install -g eslint
- Initialize ESLint configuration in your project:
npm init @eslint/config@latest
- 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"or0- turn the rule off"warn"or1- turn the rule on as a warning"error"or2- 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
- Install dependencies:
npm install
- Run ESLint on your codebase:
npx eslint .
- 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
-
SSL Support Error:
- Ensure your Node.js installation includes SSL support
- Use an official Node.js distribution
-
pnpm Compatibility Issues:
- Add the recommended
.npmrcsettings - Use
node-linker=hoistedfor better compatibility
- Add the recommended
-
Configuration Not Found:
- Ensure
eslint.config.jsis in your project root - Verify the configuration syntax is correct
- Ensure
Getting Help
- Documentation: ESLint Docs
- Rules Reference: ESLint Rules
- Community Support: ESLint Discord
- Bug Reports: Report Issues
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.