eslint-plugin-depend

raw JSON →
1.5.0 verified Sat Apr 25 auth: no javascript

An ESLint plugin (v1.5.0) that suggests optimized dependencies, native alternatives, and detects package bloat. It helps reduce dependency tree size and redundant polyfills by analyzing imports and providing rule-based suggestions. Active development with regular releases; supports flat config and legacy config. Ships TypeScript types. Requires eslint >=8.40.0 and is ESM-only since v1.0.0.

error Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
cause Using require() to import eslint-plugin-depend which is ESM-only since v1.0.0
fix
Switch to import syntax or downgrade to v0.12.0 (last CJS version).
error Oops! Something went wrong! :( ESLint: 8.x.x ESLint couldn't find the plugin "eslint-plugin-depend"
cause Missing or incorrectly configured plugin in flat config
fix
Ensure you have import depend from 'eslint-plugin-depend' and plugins: { depend } in your config.
error Configuration for rule "depend/ban-dependencies" is invalid: Value "error" should be a boolean or object.
cause Using string severity in flat config; flat config expects severity as number or string but rule config is nested incorrectly.
fix
Use "depend/ban-dependencies": "error" inside rules object, not as a string value in extends.
error TypeError: eslint-plugin-depend is not a function
cause Importing the plugin incorrectly (e.g., using default export as function).
fix
Import as import depend from 'eslint-plugin-depend' and use as plugin object.
breaking v1.0.0 dropped CommonJS support. require() will fail.
fix Migrate to ESM: use import statements and flat config.
breaking v1.0.0 changed the default export. The plugin object no longer requires .default.
fix import depend from 'eslint-plugin-depend' (not require(...).default).
deprecated Legacy .eslintrc configs are still supported but not recommended.
fix Use flat config with eslint.config.js and the 'depend/flat/recommended' extends.
gotcha When linting package.json, you must use a JSON parser (e.g., @eslint/json or jsonc-eslint-parser) and set files: ['package.json'].
fix Add a separate config block for package.json with appropriate language/parser.
npm install eslint-plugin-depend
yarn add eslint-plugin-depend
pnpm add eslint-plugin-depend

Shows how to set up the plugin with flat config for JS files, including the correct import and extends pattern.

// Install: npm i -D eslint-plugin-depend

// eslint.config.js (flat config)
import depend from 'eslint-plugin-depend';
import { defineConfig } from 'eslint/config';

export default defineConfig([
  {
    files: ['**/*.js'],
    plugins: {
      depend
    },
    extends: ['depend/flat/recommended'],
  }
]);

// or .eslintrc.json (legacy)
// {
//   "extends": ["plugin:depend/recommended"]
// }