Skip to main content

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.

eslint.config.mjs
export default tseslint.config({
rules: {
"@typescript-eslint/no-unnecessary-parameter-property-assignment": "error"
}
});

Try this rule in the playground ↗

Examples

class Foo {
constructor(public bar: string) {
this.bar = bar;
}
}
Open in Playground

Options

This rule is not configurable.

When Not To Use It

If you don't use parameter properties, you can ignore this rule.

Resources