diff --git a/__tests__/src/rules/role-has-required-aria-props-test.js b/__tests__/src/rules/role-has-required-aria-props-test.js index fc4f53e4..0ca4e23f 100644 --- a/__tests__/src/rules/role-has-required-aria-props-test.js +++ b/__tests__/src/rules/role-has-required-aria-props-test.js @@ -10,9 +10,6 @@ import { roles } from 'aria-query'; import { RuleTester } from 'eslint'; -import iterFrom from 'es-iterator-helpers/Iterator.from'; -import map from 'es-iterator-helpers/Iterator.prototype.map'; -import toArray from 'es-iterator-helpers/Iterator.prototype.toArray'; import parserOptionsMapper from '../../__util__/parserOptionsMapper'; import parsers from '../../__util__/helpers/parsers'; @@ -42,7 +39,7 @@ const componentsSettings = { }; // Create basic test cases using all valid role types. -const basicValidityTests = toArray(map(iterFrom(roles.keys()), (role) => { +const basicValidityTests = roles.keys().map((role) => { const { requiredProps: requiredPropKeyValues, } = roles.get(role); @@ -52,7 +49,7 @@ const basicValidityTests = toArray(map(iterFrom(roles.keys()), (role) => { return { code: `
`, }; -})); +}); ruleTester.run('role-has-required-aria-props', rule, { valid: parsers.all([].concat( diff --git a/__tests__/src/rules/role-supports-aria-props-test.js b/__tests__/src/rules/role-supports-aria-props-test.js index 339b9405..46755c97 100644 --- a/__tests__/src/rules/role-supports-aria-props-test.js +++ b/__tests__/src/rules/role-supports-aria-props-test.js @@ -14,10 +14,6 @@ import { import { RuleTester } from 'eslint'; import { version as eslintVersion } from 'eslint/package.json'; import semver from 'semver'; -import iterFrom from 'es-iterator-helpers/Iterator.from'; -import filter from 'es-iterator-helpers/Iterator.prototype.filter'; -import map from 'es-iterator-helpers/Iterator.prototype.map'; -import toArray from 'es-iterator-helpers/Iterator.prototype.toArray'; import parserOptionsMapper from '../../__util__/parserOptionsMapper'; import parsers from '../../__util__/helpers/parsers'; @@ -50,27 +46,26 @@ const componentsSettings = { }, }; -const nonAbstractRoles = toArray(filter(iterFrom(roles.keys()), (role) => roles.get(role).abstract === false)); +const nonAbstractRoles = roles.keys().filter((role) => roles.get(role).abstract === false); const createTests = (rolesNames) => rolesNames.reduce((tests, role) => { const { props: propKeyValues, } = roles.get(role); const validPropsForRole = Object.keys(propKeyValues); - const invalidPropsForRole = filter( - map(iterFrom(aria.keys()), (attribute) => attribute.toLowerCase()), - (attribute) => validPropsForRole.indexOf(attribute) === -1, - ); + const invalidPropsForRole = aria.keys() + .map((attribute) => attribute.toLowerCase()) + .filter((attribute) => validPropsForRole.indexOf(attribute) === -1); const normalRole = role.toLowerCase(); return [ tests[0].concat(validPropsForRole.map((prop) => ({ code: `
`, }))), - tests[1].concat(toArray(map(invalidPropsForRole, (prop) => ({ + tests[1].concat(invalidPropsForRole.map((prop) => ({ code: `
`, errors: [errorMessage(prop.toLowerCase(), normalRole, 'div', false)], - })))), + }))), ]; }, [[], []]); @@ -413,7 +408,7 @@ ruleTester.run('role-supports-aria-props', rule, { } /> ); - + const Hello = (props) =>
{props.frag}
; `, } : [], diff --git a/package.json b/package.json index 70a22c8d..08ec83dd 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,6 @@ "axobject-query": "^4.1.0", "damerau-levenshtein": "^1.0.8", "emoji-regex": "^9.2.2", - "es-iterator-helpers": "^1.1.0", "hasown": "^2.0.2", "jsx-ast-utils": "^3.3.5", "language-tags": "^1.0.9", diff --git a/src/rules/aria-role.js b/src/rules/aria-role.js index 6b85ae85..4e2dfd33 100644 --- a/src/rules/aria-role.js +++ b/src/rules/aria-role.js @@ -9,8 +9,6 @@ import { dom, roles } from 'aria-query'; import { getLiteralPropValue, propName } from 'jsx-ast-utils'; -import iterFrom from 'es-iterator-helpers/Iterator.from'; -import filter from 'es-iterator-helpers/Iterator.prototype.filter'; import getElementType from '../util/getElementType'; import { generateObjSchema } from '../util/schemas'; @@ -31,7 +29,7 @@ const schema = generateObjSchema({ }, }); -const validRoles = new Set(filter(iterFrom(roles.keys()), (role) => roles.get(role).abstract === false)); +const validRoles = new Set(roles.keys().filter((role) => roles.get(role).abstract === false)); export default { meta: { diff --git a/src/rules/interactive-supports-focus.js b/src/rules/interactive-supports-focus.js index e872c5d1..ce6cb448 100644 --- a/src/rules/interactive-supports-focus.js +++ b/src/rules/interactive-supports-focus.js @@ -36,8 +36,7 @@ import getTabIndex from '../util/getTabIndex'; // ---------------------------------------------------------------------------- const schema = generateObjSchema({ - // TODO: convert to use iterFilter and iterFrom - tabbable: enumArraySchema([...roles.keys()].filter((name) => ( + tabbable: enumArraySchema(roles.keys().filter((name) => ( !roles.get(name).abstract && roles.get(name).superClass.some((klasses) => includes(klasses, 'widget')) ))), diff --git a/src/rules/role-supports-aria-props.js b/src/rules/role-supports-aria-props.js index f9ada8f6..93f529b4 100644 --- a/src/rules/role-supports-aria-props.js +++ b/src/rules/role-supports-aria-props.js @@ -18,8 +18,6 @@ import { getPropValue, propName, } from 'jsx-ast-utils'; -import iterFrom from 'es-iterator-helpers/Iterator.from'; -import filter from 'es-iterator-helpers/Iterator.prototype.filter'; import { generateObjSchema } from '../util/schemas'; import getElementType from '../util/getElementType'; @@ -64,11 +62,11 @@ export default { return; } - // Make sure it has no aria-* properties defined outside of its property set. + // Make sure it has no aria-* properties defined outside its property set. const { props: propKeyValues, } = roles.get(roleValue); - const invalidAriaPropsForRole = new Set(filter(iterFrom(aria.keys()), (attribute) => !(attribute in propKeyValues))); + const invalidAriaPropsForRole = new Set(aria.keys().filter((attribute) => !(attribute in propKeyValues))); node.attributes.filter((prop) => ( getPropValue(prop) != null // Ignore the attribute if its value is null or undefined. diff --git a/src/util/isAbstractRole.js b/src/util/isAbstractRole.js index 723ff1bc..89ff4b31 100644 --- a/src/util/isAbstractRole.js +++ b/src/util/isAbstractRole.js @@ -3,10 +3,8 @@ import { roles, } from 'aria-query'; import { getProp, getLiteralPropValue } from 'jsx-ast-utils'; -import iterFrom from 'es-iterator-helpers/Iterator.from'; -import filter from 'es-iterator-helpers/Iterator.prototype.filter'; -const abstractRoles = new Set(filter(iterFrom(roles.keys()), (role) => roles.get(role).abstract)); +const abstractRoles = new Set(roles.keys().filter((role) => roles.get(role).abstract)); const DOMElements = new Set(dom.keys()); diff --git a/src/util/isInteractiveElement.js b/src/util/isInteractiveElement.js index e317c910..320c3495 100644 --- a/src/util/isInteractiveElement.js +++ b/src/util/isInteractiveElement.js @@ -13,10 +13,6 @@ import { } from 'axobject-query'; import includes from 'array-includes'; import flatMap from 'array.prototype.flatmap'; -import iterFrom from 'es-iterator-helpers/Iterator.from'; -// import iterFlatMap from 'es-iterator-helpers/Iterator.prototype.flatMap'; -import filter from 'es-iterator-helpers/Iterator.prototype.filter'; -import some from 'es-iterator-helpers/Iterator.prototype.some'; import attributesComparator from './attributesComparator'; @@ -55,21 +51,18 @@ const interactiveRoles = new Set(roleKeys 'toolbar', )); -// TODO: convert to use iterFlatMap and iterFrom const interactiveElementRoleSchemas = flatMap( elementRoleEntries, ([elementSchema, rolesArr]) => (rolesArr.some((role): boolean => interactiveRoles.has(role)) ? [elementSchema] : []), ); -// TODO: convert to use iterFlatMap and iterFrom const nonInteractiveElementRoleSchemas = flatMap( elementRoleEntries, ([elementSchema, rolesArr]) => (rolesArr.every((role): boolean => nonInteractiveRoles.has(role)) ? [elementSchema] : []), ); -const interactiveAXObjects = new Set(filter(iterFrom(AXObjects.keys()), (name) => AXObjects.get(name).type === 'widget')); +const interactiveAXObjects = new Set(AXObjects.keys().filter((name) => AXObjects.get(name).type === 'widget')); -// TODO: convert to use iterFlatMap and iterFrom const interactiveElementAXObjectSchemas = flatMap( [...elementAXObjects], ([elementSchema, AXObjectsArr]) => (AXObjectsArr.every((role): boolean => interactiveAXObjects.has(role)) ? [elementSchema] : []), @@ -85,18 +78,18 @@ function checkIsInteractiveElement(tagName, attributes): boolean { // Check in elementRoles for inherent interactive role associations for // this element. - const isInherentInteractiveElement = some(iterFrom(interactiveElementRoleSchemas), elementSchemaMatcher); + const isInherentInteractiveElement = interactiveElementRoleSchemas.some(elementSchemaMatcher); if (isInherentInteractiveElement) { return true; } // Check in elementRoles for inherent non-interactive role associations for // this element. - const isInherentNonInteractiveElement = some(iterFrom(nonInteractiveElementRoleSchemas), elementSchemaMatcher); + const isInherentNonInteractiveElement = nonInteractiveElementRoleSchemas.some(elementSchemaMatcher); if (isInherentNonInteractiveElement) { return false; } // Check in elementAXObjects for AX Tree associations for this element. - const isInteractiveAXElement = some(iterFrom(interactiveElementAXObjectSchemas), elementSchemaMatcher); + const isInteractiveAXElement = interactiveElementAXObjectSchemas.some(elementSchemaMatcher); if (isInteractiveAXElement) { return true; } diff --git a/src/util/isNonInteractiveElement.js b/src/util/isNonInteractiveElement.js index 034cb716..ff562cff 100644 --- a/src/util/isNonInteractiveElement.js +++ b/src/util/isNonInteractiveElement.js @@ -14,10 +14,6 @@ import { import type { Node } from 'ast-types-flow'; import includes from 'array-includes'; import flatMap from 'array.prototype.flatmap'; -import iterFrom from 'es-iterator-helpers/Iterator.from'; -// import iterFlatMap from 'es-iterator-helpers/Iterator.prototype.flatMap'; -import filter from 'es-iterator-helpers/Iterator.prototype.filter'; -import some from 'es-iterator-helpers/Iterator.prototype.some'; import attributesComparator from './attributesComparator'; @@ -62,21 +58,18 @@ const interactiveRoles = new Set(roleKeys 'toolbar', )); -// TODO: convert to use iterFlatMap and iterFrom const interactiveElementRoleSchemas = flatMap( elementRoleEntries, ([elementSchema, rolesArr]) => (rolesArr.some((role): boolean => interactiveRoles.has(role)) ? [elementSchema] : []), ); -// TODO: convert to use iterFlatMap and iterFrom const nonInteractiveElementRoleSchemas = flatMap( elementRoleEntries, ([elementSchema, rolesArr]) => (rolesArr.every((role): boolean => nonInteractiveRoles.has(role)) ? [elementSchema] : []), ); -const nonInteractiveAXObjects = new Set(filter(iterFrom(AXObjects.keys()), (name) => includes(['window', 'structure'], AXObjects.get(name).type))); +const nonInteractiveAXObjects = new Set(AXObjects.keys().filter((name) => includes(['window', 'structure'], AXObjects.get(name).type))); -// TODO: convert to use iterFlatMap and iterFrom const nonInteractiveElementAXObjectSchemas = flatMap( [...elementAXObjects], ([elementSchema, AXObjectsArr]) => (AXObjectsArr.every((role): boolean => nonInteractiveAXObjects.has(role)) ? [elementSchema] : []), @@ -92,18 +85,18 @@ function checkIsNonInteractiveElement(tagName, attributes): boolean { } // Check in elementRoles for inherent non-interactive role associations for // this element. - const isInherentNonInteractiveElement = some(iterFrom(nonInteractiveElementRoleSchemas), elementSchemaMatcher); + const isInherentNonInteractiveElement = nonInteractiveElementRoleSchemas.some(elementSchemaMatcher); if (isInherentNonInteractiveElement) { return true; } // Check in elementRoles for inherent interactive role associations for // this element. - const isInherentInteractiveElement = some(iterFrom(interactiveElementRoleSchemas), elementSchemaMatcher); + const isInherentInteractiveElement = interactiveElementRoleSchemas.some(elementSchemaMatcher); if (isInherentInteractiveElement) { return false; } // Check in elementAXObjects for AX Tree associations for this element. - const isNonInteractiveAXElement = some(iterFrom(nonInteractiveElementAXObjectSchemas), elementSchemaMatcher); + const isNonInteractiveAXElement = nonInteractiveElementAXObjectSchemas.some(elementSchemaMatcher); if (isNonInteractiveAXElement) { return true; }