From 4c0a5e5a67941aff1b1c1221fe82f49da8cf55b9 Mon Sep 17 00:00:00 2001 From: Bhavya RM Date: Thu, 1 Nov 2018 12:47:16 -0400 Subject: [PATCH] Adding jsxa11y into eslint rules (#23932) --- .eslintrc.js | 13 ++++++ package.json | 1 + packages/eslint-config-kibana/.eslintrc.js | 27 +++++++++++- packages/eslint-config-kibana/package.json | 1 + yarn.lock | 49 ++++++++++++++++++++++ 5 files changed, 90 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 501f7da4d2cce..09c20449e6841 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -315,6 +315,19 @@ module.exports = { }, }, + /** + * disable jsx-a11y for kbn-ui-framework + */ + { + files: ['packages/kbn-ui-framework/**'], + rules: { + 'jsx-a11y/click-events-have-key-events': 'off', + 'jsx-a11y/anchor-has-content': 'off', + 'jsx-a11y/tabindex-no-positive': 'off', + 'jsx-a11y/aria-role': 'off', + }, + }, + /** * Monitoring overrides */ diff --git a/package.json b/package.json index 327f8ec4b0b21..a2d2cbb340119 100644 --- a/package.json +++ b/package.json @@ -288,6 +288,7 @@ "eslint-plugin-babel": "^5.2.0", "eslint-plugin-import": "^2.14.0", "eslint-plugin-jest": "^21.22.1", + "eslint-plugin-jsx-a11y": "^6.1.2", "eslint-plugin-mocha": "^5.2.0", "eslint-plugin-no-unsanitized": "^3.0.2", "eslint-plugin-prefer-object-spread": "^1.2.1", diff --git a/packages/eslint-config-kibana/.eslintrc.js b/packages/eslint-config-kibana/.eslintrc.js index c14d0268e1578..d2d1efa9180fa 100644 --- a/packages/eslint-config-kibana/.eslintrc.js +++ b/packages/eslint-config-kibana/.eslintrc.js @@ -10,8 +10,9 @@ module.exports = { 'import', 'no-unsanitized', 'prefer-object-spread', + 'jsx-a11y', ], - + env: { es6: true, node: true, @@ -116,6 +117,30 @@ module.exports = { arrow: true, }], 'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'], + 'jsx-a11y/accessible-emoji': 'error', + 'jsx-a11y/alt-text': 'error', + 'jsx-a11y/anchor-has-content': 'error', + 'jsx-a11y/aria-activedescendant-has-tabindex': 'error', + 'jsx-a11y/aria-props': 'error', + 'jsx-a11y/aria-proptypes': 'error', + 'jsx-a11y/aria-role': 'error', + 'jsx-a11y/aria-unsupported-elements': 'error', + 'jsx-a11y/heading-has-content': 'error', + 'jsx-a11y/html-has-lang': 'error', + 'jsx-a11y/iframe-has-title': 'error', + 'jsx-a11y/interactive-supports-focus': 'error', + 'jsx-a11y/media-has-caption': 'error', + 'jsx-a11y/mouse-events-have-key-events': 'error', + 'jsx-a11y/no-access-key': 'error', + 'jsx-a11y/no-distracting-elements': 'error', + 'jsx-a11y/no-interactive-element-to-noninteractive-role': 'error', + 'jsx-a11y/no-noninteractive-element-interactions': 'error', + 'jsx-a11y/no-noninteractive-element-to-interactive-role': 'error', + 'jsx-a11y/no-redundant-roles': 'error', + 'jsx-a11y/role-has-required-aria-props': 'error', + 'jsx-a11y/role-supports-aria-props': 'error', + 'jsx-a11y/scope': 'error', + 'jsx-a11y/tabindex-no-positive': 'error', 'react/jsx-equals-spacing': ['error', 'never'], 'react/jsx-indent': ['error', 2], 'react/no-will-update-set-state': 'error', diff --git a/packages/eslint-config-kibana/package.json b/packages/eslint-config-kibana/package.json index bb393553e987a..d2e639eebbbe3 100644 --- a/packages/eslint-config-kibana/package.json +++ b/packages/eslint-config-kibana/package.json @@ -18,6 +18,7 @@ "babel-eslint": "^9.0.0", "eslint": "^5.6.0", "eslint-plugin-babel": "^5.2.0", + "eslint-plugin-jsx-a11y": "^6.1.2", "eslint-plugin-import": "^2.14.0", "eslint-plugin-jest": "^21.22.1", "eslint-plugin-mocha": "^5.2.0", diff --git a/yarn.lock b/yarn.lock index bf33be0f13ff4..db06d43581eae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1586,6 +1586,14 @@ argparse@~0.1.15: underscore "~1.7.0" underscore.string "~2.4.0" +aria-query@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-3.0.0.tgz#65b3fcc1ca1155a8c9ae64d6eee297f15d5133cc" + integrity sha1-ZbP8wcoRVajJrmTW7uKX8V1RM8w= + dependencies: + ast-types-flow "0.0.7" + commander "^2.11.0" + arr-diff@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" @@ -1748,6 +1756,11 @@ ast-transform@0.0.0: esprima "~1.0.4" through "~2.3.4" +ast-types-flow@0.0.7, ast-types-flow@^0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/ast-types-flow/-/ast-types-flow-0.0.7.tgz#f70b735c6bca1a5c9c22d982c3e39e7feba3bdad" + integrity sha1-9wtzXGvKGlycItmCw+Oef+ujva0= + ast-types@^0.7.0: version "0.7.8" resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.7.8.tgz#902d2e0d60d071bdcd46dc115e1809ed11c138a9" @@ -1888,6 +1901,13 @@ axios@^0.18.0: follow-redirects "^1.3.0" is-buffer "^1.1.5" +axobject-query@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.0.2.tgz#ea187abe5b9002b377f925d8bf7d1c561adf38f9" + integrity sha512-MCeek8ZH7hKyO1rWUbKNQBbl4l2eY0ntk7OGi+q0RlafrCnfPxC06WZA+uebCfmYp4mNU9jRBP1AhGyf8+W3ww== + dependencies: + ast-types-flow "0.0.7" + b64@4.x.x: version "4.0.0" resolved "https://registry.yarnpkg.com/b64/-/b64-4.0.0.tgz#c37f587f0a383c7019e821120e8c3f58f0d22772" @@ -3980,6 +4000,11 @@ commander@2.9.0, commander@~2.9.0: dependencies: graceful-readlink ">= 1.0.0" +commander@^2.11.0: + version "2.19.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a" + integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg== + commander@~2.13.0: version "2.13.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c" @@ -4794,6 +4819,11 @@ d@1: dependencies: es5-ext "^0.10.9" +damerau-levenshtein@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/damerau-levenshtein/-/damerau-levenshtein-1.0.4.tgz#03191c432cb6eea168bb77f3a55ffdccb8978514" + integrity sha1-AxkcQyy27qFou3fzpV/9zLiXhRQ= + dashdash@^1.12.0: version "1.14.1" resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" @@ -5443,6 +5473,11 @@ elliptic@^6.0.0: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.0" +emoji-regex@^6.5.1: + version "6.5.1" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-6.5.1.tgz#9baea929b155565c11ea41c6626eaa65cef992c2" + integrity sha512-PAHp6TxrCy7MGMFidro8uikr+zlJJKJ/Q6mm2ExZ7HwkyR9lSVFfE3kt36qcwa24BQL7y0G9axycGjK1A/0uNQ== + emojis-list@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" @@ -5861,6 +5896,20 @@ eslint-plugin-jest@^21.22.1: resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-21.22.1.tgz#bc805e9b1c75c3bc92e47c44dd41370c1af7ebcc" integrity sha512-OcVizyXljSps3nVfuPomfK8RKt7jvDsIsDrO7l1ZA4bDbiO9bEGWpsdU/x5F0pymVDG7ME88VlTboxbYJumLGQ== +eslint-plugin-jsx-a11y@^6.1.2: + version "6.1.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.1.2.tgz#69bca4890b36dcf0fe16dd2129d2d88b98f33f88" + integrity sha512-7gSSmwb3A+fQwtw0arguwMdOdzmKUgnUcbSNlo+GjKLAQFuC2EZxWqG9XHRI8VscBJD5a8raz3RuxQNFW+XJbw== + dependencies: + aria-query "^3.0.0" + array-includes "^3.0.3" + ast-types-flow "^0.0.7" + axobject-query "^2.0.1" + damerau-levenshtein "^1.0.4" + emoji-regex "^6.5.1" + has "^1.0.3" + jsx-ast-utils "^2.0.1" + eslint-plugin-mocha@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/eslint-plugin-mocha/-/eslint-plugin-mocha-5.2.0.tgz#d8786d9fff8cb8b5f6e4b61e40395d6568a5c4e2"