From 717e9b0a34a510beb94f7e92e0577f859e3c4d22 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Fri, 23 Sep 2022 14:02:16 +0100 Subject: [PATCH] add eslint-plugin-jsx-a11y (#55677) --- .eslintrc | 63 ++++++++++++++++++++++++++- package.json | 1 + yarn.lock | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 180 insertions(+), 3 deletions(-) diff --git a/.eslintrc b/.eslintrc index e590e63be15..5e935e5932f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,7 +1,7 @@ { "extends": ["@grafana/eslint-config"], "root": true, - "plugins": ["@emotion", "lodash", "jest", "import"], + "plugins": ["@emotion", "lodash", "jest", "import", "jsx-a11y"], "settings": { "import/internal-regex": "^(app/)|(@grafana)", "import/external-module-folders": ["node_modules", ".yarn"] @@ -34,7 +34,66 @@ // Use typescript's no-redeclare for compatibility with overrides "no-redeclare": "off", - "@typescript-eslint/no-redeclare": ["error"] + "@typescript-eslint/no-redeclare": ["error"], + + + // these are all the rules listed in the strict preset + // we should fix them one by one and mark them as errors + // once they're all fixed, we can remove them all and instead extend the strict preset + // with "extends": ["plugin:jsx-a11y/strict"] + "jsx-a11y/alt-text": "off", + "jsx-a11y/anchor-has-content": "off", + "jsx-a11y/anchor-is-valid": "off", + "jsx-a11y/aria-activedescendant-has-tabindex": "off", + "jsx-a11y/aria-props": "off", + "jsx-a11y/aria-proptypes": "off", + "jsx-a11y/aria-role": "off", + "jsx-a11y/aria-unsupported-elements": "off", + "jsx-a11y/autocomplete-valid": "off", + "jsx-a11y/click-events-have-key-events": "off", + "jsx-a11y/heading-has-content": "off", + "jsx-a11y/html-has-lang": "off", + "jsx-a11y/iframe-has-title": "off", + "jsx-a11y/img-redundant-alt": "off", + "jsx-a11y/interactive-supports-focus": [ + "off", + { + "tabbable": [ + "button", + "checkbox", + "link", + "progressbar", + "searchbox", + "slider", + "spinbutton", + "switch", + "textbox" + ] + } + ], + "jsx-a11y/label-has-associated-control": "off", + "jsx-a11y/media-has-caption": "off", + "jsx-a11y/mouse-events-have-key-events": "off", + "jsx-a11y/no-access-key": "off", + "jsx-a11y/no-autofocus": "off", + "jsx-a11y/no-distracting-elements": "off", + "jsx-a11y/no-interactive-element-to-noninteractive-role": "off", + "jsx-a11y/no-noninteractive-element-interactions": [ + "off", + { + "body": ["onError", "onLoad"], + "iframe": ["onError", "onLoad"], + "img": ["onError", "onLoad"] + } + ], + "jsx-a11y/no-noninteractive-element-to-interactive-role": "off", + "jsx-a11y/no-noninteractive-tabindex": "off", + "jsx-a11y/no-redundant-roles": "off", + "jsx-a11y/no-static-element-interactions": "off", + "jsx-a11y/role-has-required-aria-props": "off", + "jsx-a11y/role-supports-aria-props": "off", + "jsx-a11y/scope": "off", + "jsx-a11y/tabindex-no-positive": "off" }, "overrides": [ { diff --git a/package.json b/package.json index 5e6ee60066d..362713dd645 100644 --- a/package.json +++ b/package.json @@ -184,6 +184,7 @@ "eslint-plugin-import": "^2.26.0", "eslint-plugin-jest": "26.6.0", "eslint-plugin-jsdoc": "39.3.3", + "eslint-plugin-jsx-a11y": "6.6.1", "eslint-plugin-lodash": "7.4.0", "eslint-plugin-react": "7.31.0", "eslint-plugin-react-hooks": "4.6.0", diff --git a/yarn.lock b/yarn.lock index 5c76a9cbfd8..44615542c4d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3918,7 +3918,17 @@ __metadata: languageName: node linkType: hard -"@babel/runtime@npm:7.19.0": +"@babel/runtime-corejs3@npm:^7.10.2": + version: 7.19.1 + resolution: "@babel/runtime-corejs3@npm:7.19.1" + dependencies: + core-js-pure: ^3.25.1 + regenerator-runtime: ^0.13.4 + checksum: 38a1e8fcd2ba1f76c951259c98a5a11052123923adbf30ec8b2fec202dbbe38c6db61658ef9398e00c30f799e2e54ea036e56a09f43229261918bf5ec1b7d03a + languageName: node + linkType: hard + +"@babel/runtime@npm:7.19.0, @babel/runtime@npm:^7.18.9": version: 7.19.0 resolution: "@babel/runtime@npm:7.19.0" dependencies: @@ -14326,6 +14336,16 @@ __metadata: languageName: node linkType: hard +"aria-query@npm:^4.2.2": + version: 4.2.2 + resolution: "aria-query@npm:4.2.2" + dependencies: + "@babel/runtime": ^7.10.2 + "@babel/runtime-corejs3": ^7.10.2 + checksum: 38401a9a400f26f3dcc24b84997461a16b32869a9893d323602bed8da40a8bcc0243b8d2880e942249a1496cea7a7de769e93d21c0baa439f01e1ee936fed665 + languageName: node + linkType: hard + "aria-query@npm:^5.0.0": version: 5.0.0 resolution: "aria-query@npm:5.0.0" @@ -14609,6 +14629,13 @@ __metadata: languageName: node linkType: hard +"ast-types-flow@npm:^0.0.7": + version: 0.0.7 + resolution: "ast-types-flow@npm:0.0.7" + checksum: a26dcc2182ffee111cad7c471759b0bda22d3b7ebacf27c348b22c55f16896b18ab0a4d03b85b4020dce7f3e634b8f00b593888f622915096ea1927fa51866c4 + languageName: node + linkType: hard + "ast-types@npm:^0.14.2": version: 0.14.2 resolution: "ast-types@npm:0.14.2" @@ -14759,6 +14786,13 @@ __metadata: languageName: node linkType: hard +"axe-core@npm:^4.4.3": + version: 4.4.3 + resolution: "axe-core@npm:4.4.3" + checksum: c3ea000d9ace3ba0bc747c8feafc24b0de62a0f7d93021d0f77b19c73fca15341843510f6170da563d51535d6cfb7a46c5fc0ea36170549dbb44b170208450a2 + languageName: node + linkType: hard + "axios@npm:0.27.2": version: 0.27.2 resolution: "axios@npm:0.27.2" @@ -14787,6 +14821,13 @@ __metadata: languageName: node linkType: hard +"axobject-query@npm:^2.2.0": + version: 2.2.0 + resolution: "axobject-query@npm:2.2.0" + checksum: 96b8c7d807ca525f41ad9b286186e2089b561ba63a6d36c3e7d73dc08150714660995c7ad19cda05784458446a0793b45246db45894631e13853f48c1aa3117f + languageName: node + linkType: hard + "babel-jest@npm:27.5.1, babel-jest@npm:^27.5.1": version: 27.5.1 resolution: "babel-jest@npm:27.5.1" @@ -17315,6 +17356,13 @@ __metadata: languageName: node linkType: hard +"core-js-pure@npm:^3.25.1": + version: 3.25.2 + resolution: "core-js-pure@npm:3.25.2" + checksum: 8940d844f3a2474b9f51478341b682cb86d998723337f249424a7cdedd321dd2568cb0fbc459bb0f98a9427d23d1a3050aa44644ac2301fe380308ebecd6f28e + languageName: node + linkType: hard + "core-js-pure@npm:^3.8.1": version: 3.19.0 resolution: "core-js-pure@npm:3.19.0" @@ -18470,6 +18518,13 @@ __metadata: languageName: node linkType: hard +"damerau-levenshtein@npm:^1.0.8": + version: 1.0.8 + resolution: "damerau-levenshtein@npm:1.0.8" + checksum: d240b7757544460ae0586a341a53110ab0a61126570ef2d8c731e3eab3f0cb6e488e2609e6a69b46727635de49be20b071688698744417ff1b6c1d7ccd03e0de + languageName: node + linkType: hard + "dangerously-set-html-content@npm:1.0.9": version: 1.0.9 resolution: "dangerously-set-html-content@npm:1.0.9" @@ -20204,6 +20259,29 @@ __metadata: languageName: node linkType: hard +"eslint-plugin-jsx-a11y@npm:6.6.1": + version: 6.6.1 + resolution: "eslint-plugin-jsx-a11y@npm:6.6.1" + dependencies: + "@babel/runtime": ^7.18.9 + aria-query: ^4.2.2 + array-includes: ^3.1.5 + ast-types-flow: ^0.0.7 + axe-core: ^4.4.3 + axobject-query: ^2.2.0 + damerau-levenshtein: ^1.0.8 + emoji-regex: ^9.2.2 + has: ^1.0.3 + jsx-ast-utils: ^3.3.2 + language-tags: ^1.0.5 + minimatch: ^3.1.2 + semver: ^6.3.0 + peerDependencies: + eslint: ^3 || ^4 || ^5 || ^6 || ^7 || ^8 + checksum: baae7377f0e25a0cc9b34dc333a3dc6ead9ee8365e445451eff554c3ca267a0a6cb88127fe90395c578ab1b92cfed246aef7dc8d2b48b603389e10181799e144 + languageName: node + linkType: hard + "eslint-plugin-lodash@npm:7.4.0": version: 7.4.0 resolution: "eslint-plugin-lodash@npm:7.4.0" @@ -22498,6 +22576,7 @@ __metadata: eslint-plugin-import: ^2.26.0 eslint-plugin-jest: 26.6.0 eslint-plugin-jsdoc: 39.3.3 + eslint-plugin-jsx-a11y: 6.6.1 eslint-plugin-lodash: 7.4.0 eslint-plugin-react: 7.31.0 eslint-plugin-react-hooks: 4.6.0 @@ -26378,6 +26457,16 @@ __metadata: languageName: node linkType: hard +"jsx-ast-utils@npm:^3.3.2": + version: 3.3.3 + resolution: "jsx-ast-utils@npm:3.3.3" + dependencies: + array-includes: ^3.1.5 + object.assign: ^4.1.3 + checksum: a2ed78cac49a0f0c4be8b1eafe3c5257a1411341d8e7f1ac740debae003de04e5f6372bfcfbd9d082e954ffd99aac85bcda85b7c6bc11609992483f4cdc0f745 + languageName: node + linkType: hard + "junk@npm:^3.1.0": version: 3.1.0 resolution: "junk@npm:3.1.0" @@ -26519,6 +26608,22 @@ __metadata: languageName: node linkType: hard +"language-subtag-registry@npm:~0.3.2": + version: 0.3.22 + resolution: "language-subtag-registry@npm:0.3.22" + checksum: 8ab70a7e0e055fe977ac16ea4c261faec7205ac43db5e806f72e5b59606939a3b972c4bd1e10e323b35d6ffa97c3e1c4c99f6553069dad2dfdd22020fa3eb56a + languageName: node + linkType: hard + +"language-tags@npm:^1.0.5": + version: 1.0.5 + resolution: "language-tags@npm:1.0.5" + dependencies: + language-subtag-registry: ~0.3.2 + checksum: c81b5d8b9f5f9cfd06ee71ada6ddfe1cf83044dd5eeefcd1e420ad491944da8957688db4a0a9bc562df4afdc2783425cbbdfd152c01d93179cf86888903123cf + languageName: node + linkType: hard + "lazy-ass@npm:^1.6.0": version: 1.6.0 resolution: "lazy-ass@npm:1.6.0" @@ -29090,6 +29195,18 @@ __metadata: languageName: node linkType: hard +"object.assign@npm:^4.1.3": + version: 4.1.4 + resolution: "object.assign@npm:4.1.4" + dependencies: + call-bind: ^1.0.2 + define-properties: ^1.1.4 + has-symbols: ^1.0.3 + object-keys: ^1.1.1 + checksum: 76cab513a5999acbfe0ff355f15a6a125e71805fcf53de4e9d4e082e1989bdb81d1e329291e1e4e0ae7719f0e4ef80e88fb2d367ae60500d79d25a6224ac8864 + languageName: node + linkType: hard + "object.entries@npm:^1.1.0, object.entries@npm:^1.1.1, object.entries@npm:^1.1.5": version: 1.1.5 resolution: "object.entries@npm:1.1.5"