no-unnecessary-parameter-property-assignment
Disallow unnecessary assignment of constructor property parameter.
TypeScript's parameter properties allow creating and initializing a member in one place. Therefore, in most cases, it is not necessary to assign parameter properties of the same name to members within a constructor.
- Flat Config
- Legacy Config
eslint.config.mjs
export default tseslint.config({
  rules: {
    "@typescript-eslint/no-unnecessary-parameter-property-assignment": "error"
  }
});
.eslintrc.cjs
module.exports = {
  "rules": {
    "@typescript-eslint/no-unnecessary-parameter-property-assignment": "error"
  }
};
Try this rule in the playground ↗
Examples
- ❌ Incorrect
- ✅ Correct
class Foo {
  constructor(public bar: string) {
    this.bar = bar;
  }
}
class Foo {
  constructor(public bar: string) {}
}
Options
This rule is not configurable.
When Not To Use It
If you don't use parameter properties, you can ignore this rule.