{"id":19825,"library":"eslint-plugin-lodash","title":"eslint-plugin-lodash","description":"ESLint plugin providing Lodash-specific linting rules for ESLint 9+. Version 8.0.0 supports ESM and CJS, automatically detects Lodash imports (require/import), and includes shared rule settings for pragma and version. Major differentiator: first Lodash plugin for ESLint, with rules covering collection method usage, chaining, callbacks, and stylistic preferences. Active maintenance, with configs for recommended, canonical, and Lodash v3.","status":"active","version":"8.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/idok/eslint-plugin-lodash","tags":["javascript","eslint","eslint-plugin","eslintplugin","lodash"],"install":[{"cmd":"npm install eslint-plugin-lodash","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-lodash","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-lodash","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; requires ESLint >=9.0.0","package":"eslint","optional":false}],"imports":[{"note":"ESM default export; CJS require() still works for Node <12 but plugin is ESM-only for v8.","wrong":"const plugin = require('eslint-plugin-lodash')","symbol":"plugin","correct":"import plugin from 'eslint-plugin-lodash'"},{"note":"Use shorthand 'lodash' for plugin and 'plugin:lodash/recommended' for config.","wrong":"module.exports = { plugins: ['eslint-plugin-lodash'], extends: ['eslint-plugin-lodash/recommended'] }","symbol":"recommended config","correct":"module.exports = { plugins: ['lodash'], extends: ['plugin:lodash/recommended'] }"},{"note":"Configs must be prefixed with 'plugin:'. The 'canonical' config assumes a single Lodash object (e.g., '_') without explicit imports.","wrong":"extends: ['lodash/canonical']","symbol":"canonical config","correct":"extends: ['plugin:lodash/canonical']"}],"quickstart":{"code":"// Install: npm install --save-dev eslint eslint-plugin-lodash\n\n// .eslintrc.json\n{\n  \"plugins\": [\"lodash\"],\n  \"extends\": [\"plugin:lodash/recommended\"],\n  \"rules\": {\n    \"lodash/callback-binding\": \"error\",\n    \"lodash/collection-method-value\": \"warn\",\n    \"lodash/collection-return\": \"error\",\n    \"lodash/no-double-unwrap\": \"error\",\n    \"lodash/no-extra-args\": \"error\",\n    \"lodash/no-unbound-this\": \"error\",\n    \"lodash/unwrap\": \"error\"\n  },\n  \"settings\": {\n    \"lodash\": {\n      \"pragma\": \"_\"\n    }\n  }\n}\n\n// Example file\nimport _ from 'lodash';\n\nconst arr = [1, 2, 3];\n// OK: _.forEach returns undefined, but collection-method-value rule warns\n_.forEach(arr, item => console.log(item));\n\n// Error: collection-return rule expects return in non-forEach iteratee\nconst doubled = _.map(arr, item => item * 2); // OK, returns value","lang":"javascript","description":"Shows installation, ESLint config for recommended rules, and examples of rule-triggering code."},"warnings":[{"fix":"Use shared settings with explicit 'pragma' if import detection fails.","message":"Version 2.0.0 changed import detection and removed support for automatic pragma detection in some cases.","severity":"breaking","affected_versions":">=2.0.0 <8.0.0"},{"fix":"Upgrade ESLint to >=9.0.0.","message":"ESLint 9+ is required; older ESLint versions are not supported.","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"Migrate to Lodash v4 or use settings.lodash.version = 3.","message":"The 'v3' config may be removed in a future major version.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use the 'recommended' config for mixed usage, or set 'pragma' to your variable name.","message":"The 'canonical' config requires the Lodash object to be assigned to the variable specified in pragma (default '_'), and does not work with imported single methods.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install eslint-plugin-lodash --save-dev' and ensure .eslintrc.json has 'plugins: [\"lodash\"]'.","cause":"Plugin not installed or ESLint config incorrectly references the plugin.","error":"ESLint couldn't find the plugin \"eslint-plugin-lodash\"."},{"fix":"Check the rule name in the official list; ensure it's included in the plugin.","cause":"Rule does not exist or is misspelled.","error":"Configuration for rule \"lodash/collection-return\" is invalid: Value \"error\" is not allowed."},{"fix":"Add 'parserOptions: { sourceType: \"module\" }' to your ESLint config.","cause":"ESLint parser does not support ES modules.","error":"Parsing error: The keyword 'import' is reserved."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}