react-a11y.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. 'use strict';
  2. module.exports = {
  3. plugins: [
  4. 'jsx-a11y',
  5. 'react',
  6. ],
  7. parserOptions: {
  8. ecmaFeatures: {
  9. jsx: true,
  10. },
  11. },
  12. rules: {
  13. // Enforce that anchors have content
  14. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md
  15. 'jsx-a11y/anchor-has-content': [ 'error', { components: [ '' ] }],
  16. // Require ARIA roles to be valid and non-abstract
  17. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md
  18. 'jsx-a11y/aria-role': 'error',
  19. // Enforce all aria-* props are valid.
  20. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md
  21. 'jsx-a11y/aria-props': 'error',
  22. // Enforce ARIA state and property values are valid.
  23. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md
  24. 'jsx-a11y/aria-proptypes': 'error',
  25. // Enforce that elements that do not support ARIA roles, states, and
  26. // properties do not have those attributes.
  27. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md
  28. 'jsx-a11y/aria-unsupported-elements': 'error',
  29. // disallow href "#"
  30. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md
  31. 'jsx-a11y/anchor-is-valid': [ 'error', { components: [ 'a' ] }],
  32. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md
  33. 'jsx-a11y/alt-text': 'error',
  34. // Prevent img alt text from containing redundant words like "image", "picture", or "photo"
  35. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md
  36. 'jsx-a11y/img-redundant-alt': 'error',
  37. // require that JSX labels use "htmlFor"
  38. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
  39. 'jsx-a11y/label-has-for': [ 'error', { components: [ 'label' ] }],
  40. // require that mouseover/out come with focus/blur, for keyboard-only users
  41. // TODO: evaluate
  42. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md
  43. 'jsx-a11y/mouse-events-have-key-events': 'off',
  44. // Prevent use of `accessKey`
  45. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md
  46. 'jsx-a11y/no-access-key': 'error',
  47. // require onBlur instead of onChange
  48. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md
  49. 'jsx-a11y/no-onchange': 'off',
  50. // Enforce that elements with onClick handlers must be focusable.
  51. // TODO: evaluate
  52. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/onclick-has-focus.md
  53. 'jsx-a11y/onclick-has-focus': 'off',
  54. // Enforce that elements with ARIA roles must have all required attributes
  55. // for that role.
  56. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md
  57. 'jsx-a11y/role-has-required-aria-props': 'error',
  58. // Enforce that elements with explicit or implicit roles defined contain
  59. // only aria-* properties supported by that role.
  60. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md
  61. 'jsx-a11y/role-supports-aria-props': 'error',
  62. // Enforce tabIndex value is not greater than zero.
  63. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md
  64. 'jsx-a11y/tabindex-no-positive': 'error',
  65. // ensure <hX> tags have content and are not aria-hidden
  66. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md
  67. 'jsx-a11y/heading-has-content': [ 'error', { components: [ '' ] }],
  68. // require HTML elements to have a "lang" prop
  69. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md
  70. 'jsx-a11y/html-has-lang': 'error',
  71. // require HTML element's lang prop to be valid
  72. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md
  73. 'jsx-a11y/lang': 'error',
  74. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-distracting-elements.md
  75. 'jsx-a11y/no-distracting-elements': [ 'error', { elements: [ 'marquee' ] }],
  76. // only allow <th> to have the "scope" attr
  77. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md
  78. 'jsx-a11y/scope': 'error',
  79. // require onClick be accompanied by onKeyUp/onKeyDown/onKeyPress
  80. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md
  81. // TODO: enable?
  82. 'jsx-a11y/click-events-have-key-events': 'off',
  83. // Enforce that DOM elements without semantic behavior not have interaction handlers
  84. // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md
  85. 'jsx-a11y/no-static-element-interactions': 'error',
  86. },
  87. };