# no-unnecessary-parameters πŸ“ Disallow parameters that receive the same value at every call. πŸ’ΌπŸš« This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config). This rule is _disabled_ in the β˜‘οΈ `unopinionated` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config). πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). This rule reports parameters that receive the same value or always use their default at every known call within the file. Removing them clarifies the function's dependencies and avoids repeating arguments. ## Examples ```js // ❌ function log(message, level) { console.log(level, message); } log('Starting', 'info'); log('Finished', 'info'); // βœ… function log(message) { console.log('info', message); } log('Starting'); log('Finished'); ``` Parameters in the middle of a signature are checked too. ```js // ❌ function format(value, unit, digits) { return `${value.toFixed(digits)}${unit}`; } format(1, 'px', 0); format(2, 'px', 1); // βœ… function format(value, digits) { return `${value.toFixed(digits)}px`; } format(1, 0); format(2, 1); ``` A constant already accessible to the function does not need to be passed repeatedly. ```js // ❌ const limit = 10; function clamp(value, maximum) { return Math.min(value, maximum); } clamp(1, limit); clamp(2, limit); // βœ… const limit = 10; function clamp(value) { return Math.min(value, limit); } clamp(1); clamp(2); ``` Calls with an omitted argument or an explicit `undefined` use the parameter's default. Explicit arguments equal to a supported constant default are checked too. ```js // ❌ function print(message, extra = false) { console.log(message, extra); } print('Starting'); print('Finished', false); print('Done', undefined); // βœ… function print(message) { console.log(message, false); } print('Starting'); print('Finished'); print('Done'); ``` Defaults referring to earlier parameters are reported too. When safe, a final default becomes a local variable: ```js // ❌ function pair(first, second = first) { return [first, second]; } pair(1); pair(2); // βœ… function pair(first) { const second = first; return [first, second]; } pair(1); pair(2); ``` Recursive calls can share a default value that must be fresh for each external call: ```js // βœ… function walk(node, seen = new Set()) { if (seen.has(node)) { return seen; } seen.add(node); return node.next ? walk(node.next, seen) : seen; } walk({next: {}}); walk({}); ``` Shallow object-destructured properties are checked independently. ```js // ❌ function run({path, verbose, dryRun = false}) { console.log(path, verbose, dryRun); } run({path: 'first', verbose: true}); run({path: 'second', verbose: true, dryRun: false}); // βœ… function run({path}) { console.log(path, true, false); } run({path: 'first'}); run({path: 'second'}); ``` Global bindings are reported but require manual changes because their values may change outside the file. ```js // ❌ /* global document: readonly */ function find(selector, root) { return root.querySelector(selector); } find('.first', document); find('.second', document); ``` ## Options Type: `object` ### minimumCallCount Type: `integer`\ Default: `2`\ Minimum: `1` The minimum number of distinct call sites required to report a parameter. Calls inside the function do not count toward this threshold. A call inside a loop still counts as one call site. Set this to `1` to check functions called only once. ```js { rules: { 'unicorn/no-unnecessary-parameters': ['error', {minimumCallCount: 1}], }, } ``` ## Supported patterns - Local functions, arrow functions, and explicit constructors. - Instance and static `#private` methods, including those in exported classes. - Primitive literals, `undefined`, `void 0`, stable identifier bindings, and omitted or default arguments. - Direct recursion forwarding an unchanged parameter. - Shallow object destructuring with static keys, renaming, defaults, and rest. Arguments must be object literals; an outer default of `{}` is supported. ## Scope and limitations Functions with unknown callers, public methods, and functions using their own `arguments` are ignored. Ambiguous arguments and nested destructuring are skipped. Files with direct `eval`, `with`, or non-strict block function declarations are skipped. Parameters named by explicit TypeScript predicate or assertion return annotations (`value is Type`, `asserts value is Type`, or `asserts value`) are ignored. With type information, inferred predicates, JSDoc predicates, and predicates in contextual function types are also recognized. When external calls use a default forwarded by recursion, only primitives and stable outer bindings are checked. Other defaults are skipped to preserve shared state. Fixes update declarations and callers together; global bindings, complex defaults, and changes affecting scope, timing, syntax, or comments require manual edits. Otherwise safe fixes become suggestions in files using a TypeScript extension or parser, `@ts-check`, or JSDoc type annotations; review types after applying them. Descriptive JSDoc is unaffected.