Urara-Blog/node_modules/.pnpm-store/v3/files/73/bfbdad252efc64dfefa1f22d4fad7c71a913ffec7f22da667c7d2b8765a2c689cc8ad6260876543883763ab41f5509a0a545acff0a5f4147c46f7d79170044
2022-08-14 01:14:53 +08:00

41 lines
1.3 KiB
Text

---
description: 'Disallow unnecessary constructors.'
---
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/no-useless-constructor** for documentation.
## Rule Details
This rule extends the base [`eslint/no-useless-constructor`](https://eslint.org/docs/rules/no-useless-constructor) rule.
It adds support for:
- constructors marked as `protected` / `private` (i.e. marking a constructor as non-public),
- `public` constructors when there is no superclass,
- constructors with only parameter properties.
## How to Use
```jsonc
{
// note you must disable the base rule as it can report incorrect errors
"no-useless-constructor": "off",
"@typescript-eslint/no-useless-constructor": ["error"]
}
```
## Options
See [`eslint/no-useless-constructor` options](https://eslint.org/docs/rules/no-useless-constructor#options).
<sup>
Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/no-useless-constructor.md)
</sup>
## Caveat
This lint rule will report on constructors whose sole purpose is to change visibility of a parent constructor.
See [discussion on this rule's lack of type information](https://github.com/typescript-eslint/typescript-eslint/issues/3820#issuecomment-917821240) for context.