From 0be7ea95f560c6afc6817d381054d914ebd0b2ca Mon Sep 17 00:00:00 2001 From: trajan0x <83933037+trajan0x@users.noreply.github.com> Date: Sun, 23 Jun 2024 23:41:48 -0400 Subject: [PATCH 01/16] [readme] remove deprecated travis ci badge; add github actions badge --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5f66a744..70916e27 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

- - build status + + CI status Date: Mon, 22 Jul 2024 02:39:43 +0100 Subject: [PATCH 02/16] [readme] fix typo in shareable config section in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 70916e27..b0ea032d 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,7 @@ export default [ ]; ``` -**Note**: Our shareable config do configure `files` or [`languageOptions.globals`](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#configuration-objects). +**Note**: Our shareable configs do NOT configure `files` or [`languageOptions.globals`](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#configuration-objects). For most of the cases, you probably want to configure some of these properties yourself. ```js From ce846e00414c41676a6a8601022059878bcc0b89 Mon Sep 17 00:00:00 2001 From: k35o Date: Thu, 15 Aug 2024 10:51:05 +0900 Subject: [PATCH 03/16] [readme] fix jsxA11y import name --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b0ea032d..70e8b49a 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,7 @@ export default [ For most of the cases, you probably want to configure some of these properties yourself. ```js -const jsxA11yRecommended = require('eslint-plugin-jsx-a11y'); +const jsxA11y = require('eslint-plugin-jsx-a11y'); const globals = require('globals'); module.exports = [ From 27ff7cbf562bf2685fd5a6062e58eb4727cb85c6 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 22 Aug 2024 13:20:25 -0700 Subject: [PATCH 04/16] [Deps] update `axe-core` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d3abfdfa..5de8a98a 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "array-includes": "^3.1.8", "array.prototype.flatmap": "^1.3.2", "ast-types-flow": "^0.0.8", - "axe-core": "^4.9.1", + "axe-core": "^4.10.0", "axobject-query": "~3.1.1", "damerau-levenshtein": "^1.0.8", "emoji-regex": "^9.2.2", From a08fbcc502d6a6fa7d01a48c5f0b895c61e8cdd5 Mon Sep 17 00:00:00 2001 From: Billy Levin Date: Thu, 22 Aug 2024 20:21:57 +0100 Subject: [PATCH 05/16] [Fix] `label-has-associated-control`: ignore undetermined label text Fixes #966 The rule no longer errors if the existence of label text cannot be determined --- .../label-has-associated-control-test.js | 4 ++++ src/rules/control-has-associated-label.js | 2 ++ src/rules/label-has-associated-control.js | 2 ++ src/util/mayHaveAccessibleLabel.js | 19 ++++++++++++++++++- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/__tests__/src/rules/label-has-associated-control-test.js b/__tests__/src/rules/label-has-associated-control-test.js index d0b4c3b3..0bd14107 100644 --- a/__tests__/src/rules/label-has-associated-control-test.js +++ b/__tests__/src/rules/label-has-associated-control-test.js @@ -49,6 +49,8 @@ const htmlForValid = [ // Glob support for controlComponents option. { code: '', options: [{ controlComponents: ['Custom*'] }] }, { code: '', options: [{ controlComponents: ['*Label'] }] }, + // Rule does not error if presence of accessible label cannot be determined + { code: '

' }, ]; const nestingValid = [ { code: '' }, @@ -74,6 +76,8 @@ const nestingValid = [ // Glob support for controlComponents option. { code: '', options: [{ controlComponents: ['Custom*'] }] }, { code: '', options: [{ controlComponents: ['*Input'] }] }, + // Rule does not error if presence of accessible label cannot be determined + { code: '' }, ]; const bothValid = [ diff --git a/src/rules/control-has-associated-label.js b/src/rules/control-has-associated-label.js index 512a5213..4a691741 100644 --- a/src/rules/control-has-associated-label.js +++ b/src/rules/control-has-associated-label.js @@ -101,6 +101,8 @@ export default ({ node, recursionDepth, labelAttributes, + elementType, + controlComponents, ); } diff --git a/src/rules/label-has-associated-control.js b/src/rules/label-has-associated-control.js index 7ee98ef6..fd66f2cf 100644 --- a/src/rules/label-has-associated-control.js +++ b/src/rules/label-has-associated-control.js @@ -87,6 +87,8 @@ export default ({ node, recursionDepth, options.labelAttributes, + elementType, + controlComponents, ); if (hasAccessibleLabel) { diff --git a/src/util/mayHaveAccessibleLabel.js b/src/util/mayHaveAccessibleLabel.js index 31acee95..186ef5e0 100644 --- a/src/util/mayHaveAccessibleLabel.js +++ b/src/util/mayHaveAccessibleLabel.js @@ -9,8 +9,9 @@ */ import includes from 'array-includes'; -import { getPropValue, propName } from 'jsx-ast-utils'; +import { getPropValue, propName, elementType as rawElementType } from 'jsx-ast-utils'; import type { JSXOpeningElement, Node } from 'ast-types-flow'; +import minimatch from 'minimatch'; function tryTrim(value: any) { return typeof value === 'string' ? value.trim() : value; @@ -46,6 +47,8 @@ export default function mayHaveAccessibleLabel( root: Node, maxDepth: number = 1, additionalLabellingProps?: Array = [], + getElementType: ((node: JSXOpeningElement) => string) = rawElementType, + controlComponents: Array = [], ): boolean { function checkElement( node: Node, @@ -77,6 +80,20 @@ export default function mayHaveAccessibleLabel( ) { return true; } + + if (node.type === 'JSXElement' && node.children.length === 0 && node.openingElement) { + // $FlowFixMe `node.openingElement` has `unknown` type + const name = getElementType(node.openingElement); + const isReactComponent = name.length > 0 && name[0] === name[0].toUpperCase(); + + if ( + isReactComponent + && !controlComponents.some((control) => minimatch(name, control)) + ) { + return true; + } + } + // Recurse into the child element nodes. if (node.children) { /* $FlowFixMe */ From 6eca2359f5457af72dbfba265b73297c9232cb3e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 30 Aug 2024 11:07:55 -0700 Subject: [PATCH 06/16] [Dev Deps] update `@babel/cli`, `@babel/core`, `@babel/eslint-parser`, `@babel/plugin-transform-flow-strip-types` --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 5de8a98a..12dbbd3d 100644 --- a/package.json +++ b/package.json @@ -42,10 +42,10 @@ "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" }, "devDependencies": { - "@babel/cli": "^7.24.7", - "@babel/core": "^7.24.7", - "@babel/eslint-parser": "^7.24.7", - "@babel/plugin-transform-flow-strip-types": "^7.24.7", + "@babel/cli": "^7.25.6", + "@babel/core": "^7.25.2", + "@babel/eslint-parser": "^7.25.1", + "@babel/plugin-transform-flow-strip-types": "^7.25.2", "@babel/register": "^7.24.6", "aud": "^2.0.4", "auto-changelog": "^2.4.0", From 05a5e4992900e0d5d61e29e13046c90797b68a7c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 30 Aug 2024 11:08:16 -0700 Subject: [PATCH 07/16] [Tests] use `npm audit` instead of `aud` --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 12dbbd3d..24f49706 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "prepublishOnly": "safe-publish-latest && npm run lint && npm run flow && npm run jest", "pretest": "npm run lint:fix && npm run flow", "test": "npm run jest", - "posttest": "aud --production", + "posttest": "npx npm@'>=10.2' audit --production", "test:ci": "npm run jest -- --ci --runInBand", "pretest:examples": "npm run build", "test:examples": "npm run test-example:legacy && npm run test-example:flat-esm && npm run test-example:flat-cjs", @@ -47,7 +47,6 @@ "@babel/eslint-parser": "^7.25.1", "@babel/plugin-transform-flow-strip-types": "^7.25.2", "@babel/register": "^7.24.6", - "aud": "^2.0.4", "auto-changelog": "^2.4.0", "babel-jest": "^24.9.0", "babel-plugin-add-module-exports": "^1.0.4", From 74d5decb6f2e42c05ce40a45630041fd695a2e7f Mon Sep 17 00:00:00 2001 From: michael faith Date: Thu, 18 Jul 2024 06:15:27 -0500 Subject: [PATCH 08/16] [Tests] remove duplicate tests --- __tests__/src/rules/anchor-is-valid-test.js | 31 ++----------------- ...oninteractive-element-interactions-test.js | 2 -- ...active-element-to-interactive-role-test.js | 2 -- .../no-static-element-interactions-test.js | 1 - .../src/rules/prefer-tag-over-role-test.js | 6 +--- 5 files changed, 4 insertions(+), 38 deletions(-) diff --git a/__tests__/src/rules/anchor-is-valid-test.js b/__tests__/src/rules/anchor-is-valid-test.js index 9fb4025e..857605a1 100644 --- a/__tests__/src/rules/anchor-is-valid-test.js +++ b/__tests__/src/rules/anchor-is-valid-test.js @@ -272,14 +272,9 @@ ruleTester.run('anchor-is-valid', rule, { options: noHrefAspect, }, - // CUSTOM COMPONENTS AND SPECIALLINK AND ASPECT + // CUSTOM COMPONENTS AND SPECIAL LINK AND ASPECT { code: '', options: componentsAndSpecialLinkAndInvalidHrefAspect }, { code: '', options: componentsAndSpecialLinkAndInvalidHrefAspect }, - { code: '', options: componentsAndSpecialLinkAndInvalidHrefAspect }, - { code: '', options: componentsAndSpecialLinkAndInvalidHrefAspect }, - { code: '', options: componentsAndSpecialLinkAndInvalidHrefAspect }, - { code: '', options: componentsAndSpecialLinkAndInvalidHrefAspect }, - )).map(parserOptionsMapper), invalid: parsers.all([].concat( // DEFAULT ELEMENT 'a' TESTS @@ -372,7 +367,7 @@ ruleTester.run('anchor-is-valid', rule, { options: specialLink, }, - // CUSTOM BOTH COMPONENTS AND SPECIALLINK TESTS + // CUSTOM BOTH COMPONENTS AND SPECIAL LINK TESTS // NO HREF { code: '', errors: [noHrefexpectedError], options: componentsAndSpecialLink }, { code: '', errors: [noHrefexpectedError], options: componentsAndSpecialLink }, @@ -522,27 +517,7 @@ ruleTester.run('anchor-is-valid', rule, { errors: [invalidHrefexpectedError], }, - // CUSTOM COMPONENTS AND SPECIALLINK AND ASPECT - { - code: '', - options: componentsAndSpecialLinkAndNoHrefAspect, - errors: [noHrefexpectedError], - }, - { - code: '', - options: componentsAndSpecialLinkAndNoHrefAspect, - errors: [noHrefexpectedError], - }, - { - code: '', - options: componentsAndSpecialLinkAndNoHrefAspect, - errors: [noHrefexpectedError], - }, - { - code: '', - options: componentsAndSpecialLinkAndNoHrefAspect, - errors: [noHrefexpectedError], - }, + // CUSTOM COMPONENTS AND SPECIAL LINK AND ASPECT { code: '', options: componentsAndSpecialLinkAndNoHrefAspect, diff --git a/__tests__/src/rules/no-noninteractive-element-interactions-test.js b/__tests__/src/rules/no-noninteractive-element-interactions-test.js index 2a82b168..c75311cd 100644 --- a/__tests__/src/rules/no-noninteractive-element-interactions-test.js +++ b/__tests__/src/rules/no-noninteractive-element-interactions-test.js @@ -336,7 +336,6 @@ const neverValid = [ { code: ' {}} />;', errors: [expectedError] }, { code: ' {}} />;', errors: [expectedError] }, { code: '
    {}} />;', errors: [expectedError] }, { code: '