{"id":19722,"library":"eslint-plugin-depend","title":"eslint-plugin-depend","description":"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.","status":"active","version":"1.5.0","language":"javascript","source_language":"en","source_url":"https://github.com/es-tooling/eslint-plugin-depend","tags":["javascript","eslint","optimize","optimise","clutter","cleanup","package","typescript"],"install":[{"cmd":"npm install eslint-plugin-depend","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-depend","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-depend","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for the plugin to function","package":"eslint","optional":false}],"imports":[{"note":"ESM-only since v1.0.0; default export is the plugin object.","wrong":"const depend = require('eslint-plugin-depend')","symbol":"default","correct":"import depend from 'eslint-plugin-depend'"},{"note":"No named default export; import the default and use as plugins.depend.","wrong":"const depend = require('eslint-plugin-depend').default","symbol":"depend (plugin)","correct":"import depend from 'eslint-plugin-depend'"},{"note":"Use 'depend/flat/recommended' string in extends; do not import a config object.","wrong":"export default [{ plugins: { 'eslint-plugin-depend': depend } }]","symbol":"flat config extension","correct":"import depend from 'eslint-plugin-depend'; export default [{ plugins: { depend }, extends: ['depend/flat/recommended'] }]"}],"quickstart":{"code":"// Install: npm i -D eslint-plugin-depend\n\n// eslint.config.js (flat config)\nimport depend from 'eslint-plugin-depend';\nimport { defineConfig } from 'eslint/config';\n\nexport default defineConfig([\n  {\n    files: ['**/*.js'],\n    plugins: {\n      depend\n    },\n    extends: ['depend/flat/recommended'],\n  }\n]);\n\n// or .eslintrc.json (legacy)\n// {\n//   \"extends\": [\"plugin:depend/recommended\"]\n// }","lang":"typescript","description":"Shows how to set up the plugin with flat config for JS files, including the correct import and extends pattern."},"warnings":[{"fix":"Migrate to ESM: use import statements and flat config.","message":"v1.0.0 dropped CommonJS support. require() will fail.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"import depend from 'eslint-plugin-depend' (not require(...).default).","message":"v1.0.0 changed the default export. The plugin object no longer requires .default.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use flat config with eslint.config.js and the 'depend/flat/recommended' extends.","message":"Legacy .eslintrc configs are still supported but not recommended.","severity":"deprecated","affected_versions":">=0.12.0"},{"fix":"Add a separate config block for package.json with appropriate language/parser.","message":"When linting package.json, you must use a JSON parser (e.g., @eslint/json or jsonc-eslint-parser) and set files: ['package.json'].","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Switch to import syntax or downgrade to v0.12.0 (last CJS version).","cause":"Using require() to import eslint-plugin-depend which is ESM-only since v1.0.0","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"},{"fix":"Ensure you have `import depend from 'eslint-plugin-depend'` and `plugins: { depend }` in your config.","cause":"Missing or incorrectly configured plugin in flat config","error":"Oops! Something went wrong! :( ESLint: 8.x.x\n\nESLint couldn't find the plugin \"eslint-plugin-depend\""},{"fix":"Use `\"depend/ban-dependencies\": \"error\"` inside rules object, not as a string value in extends.","cause":"Using string severity in flat config; flat config expects severity as number or string but rule config is nested incorrectly.","error":"Configuration for rule \"depend/ban-dependencies\" is invalid: Value \"error\" should be a boolean or object."},{"fix":"Import as `import depend from 'eslint-plugin-depend'` and use as plugin object.","cause":"Importing the plugin incorrectly (e.g., using default export as function).","error":"TypeError: eslint-plugin-depend is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}