script-utils/linters/eslint-rules/params-options-name-match
ESLint rule: params-options-name-match
Ensures that parameter-bag type names match the function or constructor they belong to, on two axes — a prefix derived from the owner and a suffix derived from how the bag is passed.
Prefix (owner): - fooBar(params: FooBar…) — PascalCase of the function name - class Baz { constructor(params: BazConstructor…) } — ClassName + Constructor - class Baz { method(params: BazMethod…) } — ClassName + PascalCase(methodName)
Suffix (whether the bag is a required sole argument): - Params only when the bag is the SOLE and REQUIRED parameter — fooBar(params: FooBarParams) - Options otherwise. That is: an OPTIONAL bag — fooBar(options?: FooBarOptions) or fooBar(options: FooBarOptions = {}) — or a bag SUPPLEMENTARY to other parameters — fooBar(baz: string, options: FooBarOptions).
Only checks parameters whose type annotation name ends with Params or Options. Only checks exported functions and members of exported classes (regardless of accessibility — public, protected, and private are all checked) to avoid false positives from internal options-passthrough helpers.
Variables
Section titled “Variables”| Variable | Description |
|---|---|
| MESSAGE_ID | Message ID reported when a parameter-bag type’s name does not match the expected name (prefix and required/optional suffix) for its function or constructor. |
| paramsOptionsNameMatch |