Programing Language/Javascript

[Javascript] A form label must be associated with a control.

pcm9881 2022. 11. 1. 14:47

원인 

label과 관련 control이 구성되도록 하는 룰.

 

해결 방법

  1. label 태그 안에 control 주체를 넣는 것.
  2. label에 for(htmlFor) 입력 control 주체에 id를 입력.
  3. 관련 설정 파일 수정.

eslintrc.json

{
    // ...
    "rules" : {
        // ...
        "jsx-a11y/label-has-associated-control": [
            2,
            {
                "labelAttributes" : ["htmlFor"]
            }
        ]
    }
}

참조

[stack overflow]: https://stackoverflow.com/questions/54446655/eslint-rule-for-label

 

EsLint rule for label

i have a problem My esLint rules: "jsx-a11y/label-has-for": [ 2, { "components": [], "required": { "every": [ "nesting", "id" ] }, "allowChildren": true }], ...

stackoverflow.com

[github]: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/label-has-associated-control.md

 

GitHub - jsx-eslint/eslint-plugin-jsx-a11y: Static AST checker for a11y rules on JSX elements.

Static AST checker for a11y rules on JSX elements. - GitHub - jsx-eslint/eslint-plugin-jsx-a11y: Static AST checker for a11y rules on JSX elements.

github.com

 

728x90