eslint-plugin-eslint-env
raw JSON → 0.6.0 verified Fri May 01 auth: no javascript
An ESLint plugin that provides a processor to lint files using eslint-env comments in an ESLint flat config. Version 0.6.0 requires ESLint >=8.21 and ships TypeScript types. It allows developers to specify environments per file via /* eslint-env */ comments, including plugin-defined environments like cypress/globals or react-native/react-native. Key differentiator: integrates eslint-env comment functionality into the flat config system, which is not natively supported by ESLint's flat config.
Common errors
error Error: Failed to load plugin 'eslint-plugin-eslint-env' declared in 'eslint.config.js': Cannot find module 'eslint-plugin-eslint-env' ↓
cause The package is not installed or is installed as a dev dependency but not resolved correctly.
fix
Run npm install -D eslint-plugin-eslint-env and ensure node_modules is present.
error TypeError: (intermediate value) is not a constructor ↓
cause Using EslintEnvProcessor without the 'new' keyword or wrong import (e.g., default import instead of named).
fix
Ensure you use import { EslintEnvProcessor } from 'eslint-plugin-eslint-env' and instantiate: new EslintEnvProcessor().
error Error: Configuration for rule 'undefined' is not found ↓
cause Missing or incorrectly structured flat config; processor not applied correctly.
fix
Verify your eslint.config.js exports an array with an object containing 'files' and 'processor' properties.
Warnings
breaking Flat config required: This plugin only works with ESLint's flat config system (eslint.config.js). Do not use with legacy .eslintrc files. ↓
fix Switch to flat config by using eslint.config.js and ensure ESLint version >=8.21.
gotcha The EslintEnvProcessor must be instantiated (new EslintEnvProcessor()) and passed as the processor option; using the string 'EslintEnvProcessor' will not work. ↓
fix Use processor: new EslintEnvProcessor() in your config object.
gotcha Plugin-defined environments require passing plugins into the processor constructor's options object. Simply adding plugins to the config is not enough. ↓
fix Pass plugins to the processor: new EslintEnvProcessor({ plugins: { 'cypress': eslintPluginCypress } }).
Install
npm install eslint-plugin-eslint-env yarn add eslint-plugin-eslint-env pnpm add eslint-plugin-eslint-env Imports
- EslintEnvProcessor wrong
import EslintEnvProcessor from 'eslint-plugin-eslint-env';correctimport { EslintEnvProcessor } from 'eslint-plugin-eslint-env'; - require/CommonJS wrong
const EslintEnvProcessor = require('eslint-plugin-eslint-env');correctconst { EslintEnvProcessor } = require('eslint-plugin-eslint-env'); - Plugin object use (legacy config) wrong
import { plugin } from 'eslint-plugin-eslint-env';correctimport plugin from 'eslint-plugin-eslint-env';
Quickstart
import { EslintEnvProcessor } from 'eslint-plugin-eslint-env';
export default [
{
files: ['**/*.js'],
processor: new EslintEnvProcessor(),
},
];