eslint-plugin-pnpm
raw JSON → 1.6.0 verified Sat Apr 25 auth: no javascript
An ESLint plugin to enforce and auto-fix pnpm catalog usage in monorepos. Current stable version is 1.6.0, released with support for ESLint v10. It provides two sets of rules: JSON rules for package.json (requires jsonc-eslint-parser) and YAML rules for pnpm-workspace.yaml (requires yaml-eslint-parser, experimental). Key differentiators include auto-fixing support, catalog enforcement, duplicate detection, and workspace protocol preferences. Maintained by Anthony Fu, with active development and monthly releases.
Common errors
error Error: Could not find config 'pnpm/json-enforce-catalog' after extending 'plugin:pnpm/recommended' ↓
cause The 'recommended' configs are not provided as plugin prefixes; configs must be imported directly.
fix
Use import { configs } from 'eslint-plugin-pnpm' and spread configs.json or configs.yaml.
error Parsing error: Unexpected token } ↓
cause Parser not set to jsonc-eslint-parser for package.json files.
fix
Add languageOptions: { parser: jsonc-eslint-parser } in the configuration for package.json files.
error Cannot find module 'eslint-plugin-pnpm' ↓
cause Missing installation or incorrect import path in ESM.
fix
Run
pnpm add -D eslint-plugin-pnpm and use import statement without file extensions. error TypeError: pluginPnpm.rules is not iterable ↓
cause Improper use of default import when spreading rules.
fix
Use the plugin object directly: plugins: { pnpm: pluginPnpm }.
Warnings
gotcha YAML rules require yaml-eslint-parser, which is experimental and may have race conditions with other plugins. ↓
fix Use with caution, or disable YAML rules if issues arise.
gotcha JSON rules require jsonc-eslint-parser as the parser for package.json files. ↓
fix Ensure the parser is configured in languageOptions.parser for relevant files.
gotcha This plugin only supports ESLint flat config (eslint.config.js), not .eslintrc. ↓
fix Migrate to flat config; the plugin does not export a deprecated configs object.
breaking ESLint v8 is not supported; requires ESLint ^9.0.0 or ^10.0.0. ↓
fix Upgrade ESLint to v9 or v10.
deprecated The rule 'json-prefer-workspace-settings' is deprecated and will be removed in a future major version. ↓
fix Use other JSON rules or manually enforce workspace protocol.
Install
npm install eslint-plugin-pnpm yarn add eslint-plugin-pnpm pnpm add eslint-plugin-pnpm Imports
- configs wrong
import { configs } from 'eslint-plugin-pnpm/configs'correctimport { configs } from 'eslint-plugin-pnpm' - default import wrong
const pluginPnpm = require('eslint-plugin-pnpm')correctimport pluginPnpm from 'eslint-plugin-pnpm' - rules wrong
import { rules } from 'eslint-plugin-pnpm/rules'correctimport { rules } from 'eslint-plugin-pnpm'
Quickstart
import { configs } from 'eslint-plugin-pnpm';
export default [
{
ignores: ['**/node_modules/**', '**/dist/**'],
},
...configs.json,
...configs.yaml,
];