Are you an LLM? You can read better optimized documentation at /docs/guide/usage/linter/rules/react/button-has-type.md for this page in Markdown format
react/button-has-type 제한
작동 방식
모든 button HTML 요소에 대해 명시적인 type 속성을 강제합니다.
왜 좋지 않은가?
button HTML 요소의 type 속성 기본값은 "submit"이며, 이는 종종 원하는 동작이 아니며 예기치 않은 페이지 리로드를 유발할 수 있습니다.
예시
이 규칙에 적합하지 않은 코드 예시:
jsx
<button />
<button type="foo" />이 규칙에 적합한 코드 예시:
jsx
<button type="button" />
<button type="submit" />구성
이 규칙은 다음 속성을 가진 구성 객체를 수락합니다:
button
type: boolean
기본값: true
true일 경우, type="button"을 허용합니다.
reset
type: boolean
기본값: true
true일 경우, type="reset"을 허용합니다.
submit
type: boolean
기본값: true
true일 경우, type="submit"을 허용합니다.
사용 방법
이 규칙을 설정 파일 또는 CLI에서 활성화하려면 다음을 사용할 수 있습니다:
json
{
"plugins": ["react"],
"rules": {
"react/button-has-type": "error"
}
}bash
oxlint --deny react/button-has-type --react-plugin