Skip to content

Commit

Permalink
Merge pull request #82 from ofk/fix/label-assert
Browse files Browse the repository at this point in the history
Fix best practices of label assert
  • Loading branch information
ofk authored Aug 3, 2024
2 parents bc09a0d + 0317443 commit 0f4ead7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions best-practices.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ module.exports = {
'import/no-default-export': 'error',
'import/prefer-default-export': 'off',

// Fix airbnb default rule.
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/label-has-associated-control.md
'jsx-a11y/label-has-associated-control': [
'error',
{
assert: 'either', // changed
controlComponents: [],
depth: 25,
labelAttributes: [],
labelComponents: [],
},
],

// Use console.{warn,error} intentionally. So suppress the warning.
// https://eslint.org/docs/rules/no-console
'no-console': [
Expand Down
3 changes: 3 additions & 0 deletions test/javascript/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const App = ({ name, onButtonClick }) => {
<div>
<Text color={text ? 'red' : undefined}>{text || 'Push button'}</Text>
<Button onClick={onClick}>Hello</Button>
<label>
<input type="checkbox" /> checkbox
</label>
</div>
);
};
Expand Down
3 changes: 3 additions & 0 deletions test/typescript/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const App: React.FC<AppProps> = ({ name, onButtonClick }) => {
<div>
<Text color={text ? 'red' : undefined}>{text ?? 'Push button'}</Text>
<Button onClick={onClick}>Hello</Button>
<label>
<input type="checkbox" /> checkbox
</label>
</div>
);
};
Expand Down

0 comments on commit 0f4ead7

Please sign in to comment.