{"id":19847,"library":"eslint-plugin-no-array-reduce","title":"eslint-plugin-no-array-reduce","description":"ESLint plugin that bans the usage of Array.prototype.reduce() in favor of more readable array methods like map, filter, and group. Version 1.0.62 (latest), maintained with regular updates. It provides a single rule that flags all reduce() calls, with an option to allow reduce() via eslint-disable comments. Differentiator: enforces a stylistic preference against reduce() with no configuration needed, unlike general-purpose ESLint rules that require custom configuration.","status":"active","version":"1.0.62","language":"javascript","source_language":"en","source_url":"https://github.com/mkosir/eslint-plugin-no-array-reduce","tags":["javascript","typescript","eslint","eslint-plugin","eslint-rules","reduce"],"install":[{"cmd":"npm install eslint-plugin-no-array-reduce","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-no-array-reduce","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-no-array-reduce","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required to load the plugin. Must be >=7.0.0.","package":"eslint","optional":false}],"imports":[{"note":"The plugin is loaded via ESLint config, not imported directly in code.","wrong":"const plugin = require('eslint-plugin-no-array-reduce')","symbol":"plugin","correct":"// In .eslintrc: { \"plugins\": [\"no-array-reduce\"] }"},{"note":"Use the recommended config to enable the rule. You can also manually configure the rule under 'rules'.","wrong":"// No common wrong import; ensure correct plugin name in 'extends'.","symbol":"recommended config","correct":"// In .eslintrc: { \"extends\": [\"plugin:no-array-reduce/recommended\"] }"},{"note":"The rule is namespaced under the plugin prefix 'no-array-reduce/' to avoid conflicts.","wrong":"// Using rule name without prefix: { \"rules\": { \"no-reduce\": \"error\" } }","symbol":"rule itself","correct":"// In .eslintrc: { \"rules\": { \"no-array-reduce/no-reduce\": \"error\" } }"}],"quickstart":{"code":"// Install the plugin\nnpm install --save-dev eslint-plugin-no-array-reduce\n\n// Add to .eslintrc.json:\n{\n  \"plugins\": [\"no-array-reduce\"],\n  \"extends\": [\"plugin:no-array-reduce/recommended\"]\n}\n\n// Example file that will fail linting:\nconst arr = [1, 2, 3];\nconst sum = arr.reduce((acc, x) => acc + x, 0);\n\n// Example file that passes:\nconst sum = arr.reduce((acc, x) => acc + x, 0); // eslint-disable-line no-array-reduce/no-reduce\n","lang":"javascript","description":"Shows installation, ESLint configuration, a failing use of reduce(), and how to disable the rule inline."},"warnings":[{"fix":"If you want to disallow reduceRight(), you need a separate rule or manual linting.","message":"The rule only flags Array.prototype.reduce() calls, not other reduce-like methods (e.g., Array.prototype.reduceRight()).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use eslint-disable comments to suppress false positives on non-Array objects.","message":"The rule triggers on any .reduce() call, including those from polyfills or custom objects that happen to have a reduce method. It does not check the receiver type.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Run npm update eslint-plugin-no-array-reduce regularly.","message":"There are no known breaking changes as the plugin is stable and v1.x only. Always upgrade to latest patch for TypeScript compatibility fixes.","severity":"deprecated","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 --save-dev eslint-plugin-no-array-reduce","cause":"The plugin is not installed or not in node_modules.","error":"ESLint: Failed to load plugin 'no-array-reduce': Cannot find module 'eslint-plugin-no-array-reduce'"},{"fix":"Use 'no-array-reduce/no-reduce' as the rule name.","cause":"Using the rule name without the plugin prefix.","error":"ESLint: Configuration for rule 'no-reduce' is invalid. Rule 'no-reduce' not found."},{"fix":"Ensure ESLint version is 7.0.0 or higher.","cause":"The plugin expects ESLint >=7.0.0 and may have issues with older versions or custom parsers.","error":"TypeError: Cannot read property 'some' of undefined (when using TypeScript parser)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}