Skip to content

Commit

Permalink
fix: allow labels to satisfy htmlFor a11y requirement instead of both…
Browse files Browse the repository at this point in the history
… nesting and htmlFor (#8)
  • Loading branch information
Adam Butterworth authored Mar 25, 2020
1 parent 6e37cfc commit b602d9c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ module.exports = {
}
],
'arrow-parens': 'off',
'jsx-a11y/label-has-associated-control': ['error', {
labelComponents: [],
labelAttributes: [],
controlComponents: [],
assert: 'htmlFor',
depth: 25
}],
'react/jsx-props-no-spreading': 'off',
'react/jsx-one-expression-per-line': 'off',
'react/destructuring-assignment': 'off',
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"lint": "./node_modules/.bin/eslint .",
"test": "./node_modules/.bin/eslint test.js"
"test": "./node_modules/.bin/eslint test.jsx"
},
"publishConfig": {
"access": "public"
Expand Down
10 changes: 10 additions & 0 deletions test.js → test.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react'; // eslint-disable-line import/no-unresolved
/* eslint-disable no-unused-vars */

// Tests for custom rules in .eslintrc.js
Expand All @@ -10,6 +11,15 @@ class MethodDoesNotUseThis {
foo() {
const bar = 'hah';
}

render() {
return (
<>
<label htmlFor="the-input">The input</label>
<input id="the-input" type="text" value="hi" />
</>
);
}
}

// disable no-plusplus
Expand Down

0 comments on commit b602d9c

Please sign in to comment.