@typescript-eslint/eslint-plugin
Version:
TypeScript plugin for ESLint
55 lines (39 loc) • 1.12 kB
text/mdx
description: 'Enforce a maximum number of parameters in function definitions.'
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/max-params** for documentation.
It adds support for TypeScript `this` parameters so they won't be counted as a parameter.
## Options
This rule adds the following options:
```ts
interface Options extends BaseMaxParamsOptions {
countVoidThis?: boolean;
}
const defaultOptions: Options = {
...baseMaxParamsOptions,
countVoidThis: false,
};
```
### `countVoidThis`
{/* insert option description */}
Example of a code when `countVoidThis` is set to `false` and `max` is `1`:
<Tabs>
<TabItem value="❌ Incorrect">
```ts option='{ "countVoidThis": false, "max": 1 }'
function hasNoThis(this: void, first: string, second: string) {
// ...
}
```
</TabItem>
<TabItem value="✅ Correct">
```ts option='{ "countVoidThis": false, "max": 1 }'
function hasNoThis(this: void, first: string) {
// ...
}
```
</TabItem>
</Tabs>