# no-useless-constructor

> Disallow constructors that do what the default constructor does

A class without a constructor gets one for free. In a base class it's empty, and in a subclass it passes all arguments to `super()`. Writing that out by hand adds lines that do nothing.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"no-useless-constructor" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 2} */}
```js
class Store {
  constructor() {}
}

class UserStore extends Store {
  constructor(name, options) {
    super(name, options);
  }
}
```

Not reported:

{/* good */}
```js
class Store {}

class UserStore extends Store {}

class CachedStore extends Store {
  constructor(name) {
    super(name, { cache: true });
  }
}
```

In TypeScript, a constructor is allowed if it's `private` or `protected`, or if its parameters declare fields:

{/* good */}
```ts
class Config {
  private constructor() {}
}

class User {
  constructor(public name: string) {}
}
```
