Skip to content

Commit 7a75461

Browse files
committed
Add Oxlint/typescript/no-unnecessary-parameter-property-assignment.md
1 parent cd2489b commit 7a75461

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Pattern: Redundant assignment of parameter property
2+
3+
Issue: -
4+
5+
## Description
6+
7+
Constructor parameters with visibility modifiers (`public`, `private`, `protected`, or `readonly`) are automatically initialized as class properties. Explicitly assigning these parameters to their corresponding properties is redundant and unnecessary.
8+
9+
## Examples
10+
11+
Example of **incorrect** code:
12+
```typescript
13+
class Foo {
14+
constructor(public name: unknown) {
15+
this.name = name; // Unnecessary assignment
16+
}
17+
}
18+
```
19+
20+
Example of **correct** code:
21+
```typescript
22+
class Foo {
23+
constructor(public name: unknown) {
24+
// No assignment needed
25+
}
26+
}
27+
```

0 commit comments

Comments
 (0)