typescript/no-unnecessary-parameter-property-assignment 정확성
작동 방식
매개변수 속성에 대한 불필요한 할당을 방지합니다.
왜 문제가 되는가?
public, private, protected, 또는 readonly와 같은 접근 제어자로 표시된 생성자 매개변수는 자동으로 초기화됩니다.
명시적인 할당을 제공하는 것은 불필요하며 제거할 수 있습니다.
예시
이 규칙에 대해 잘못된 코드 예시:
js
class Foo {
constructor(public name: unknown) {
this.name = name;
}
}이 규칙에 대해 올바른 코드 예시:
js
class Foo {
constructor(public name: unknown) {}
}사용 방법
구성 파일이나 명령줄 인터페이스를 통해 이 규칙을 활성화하려면 다음을 사용하세요:
json
{
"rules": {
"typescript/no-unnecessary-parameter-property-assignment": "error"
}
}bash
oxlint --deny typescript/no-unnecessary-parameter-property-assignment