diff --git a/package.json b/package.json index b2c870b61..cff464c14 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "axobject-query": "^3.2.1", "damerau-levenshtein": "^1.0.8", "emoji-regex": "^9.2.2", - "has": "^1.0.3", + "hasown": "^2.0.0", "jsx-ast-utils": "^3.3.5", "language-tags": "^1.0.9", "minimatch": "^3.1.2", diff --git a/src/rules/no-interactive-element-to-noninteractive-role.js b/src/rules/no-interactive-element-to-noninteractive-role.js index cc70b7cfb..7561b4e32 100644 --- a/src/rules/no-interactive-element-to-noninteractive-role.js +++ b/src/rules/no-interactive-element-to-noninteractive-role.js @@ -17,7 +17,7 @@ import { } from 'jsx-ast-utils'; import type { JSXIdentifier } from 'ast-types-flow'; import includes from 'array-includes'; -import has from 'has'; +import hasOwn from 'hasown'; import type { ESLintConfig, ESLintContext, ESLintVisitorSelectorConfig } from '../../flow/eslint'; import type { ESLintJSXAttribute } from '../../flow/eslint-jsx'; import getElementType from '../util/getElementType'; @@ -70,7 +70,7 @@ export default ({ // Allow overrides from rule configuration for specific elements and // roles. const allowedRoles = (options[0] || {}); - if (has(allowedRoles, type) && includes(allowedRoles[type], role)) { + if (hasOwn(allowedRoles, type) && includes(allowedRoles[type], role)) { return; } if ( diff --git a/src/rules/no-noninteractive-element-interactions.js b/src/rules/no-noninteractive-element-interactions.js index ee4b874a0..92e82a0a0 100644 --- a/src/rules/no-noninteractive-element-interactions.js +++ b/src/rules/no-noninteractive-element-interactions.js @@ -17,7 +17,7 @@ import { } from 'jsx-ast-utils'; import type { JSXOpeningElement } from 'ast-types-flow'; import includes from 'array-includes'; -import has from 'has'; +import hasOwn from 'hasown'; import type { ESLintConfig, ESLintContext, ESLintVisitorSelectorConfig } from '../../flow/eslint'; import { arraySchema, generateObjSchema } from '../util/schemas'; import getElementType from '../util/getElementType'; @@ -62,7 +62,7 @@ export default ({ const config = (options[0] || {}); const interactiveProps = config.handlers || defaultInteractiveProps; // Allow overrides from rule configuration for specific elements and roles. - if (has(config, type)) { + if (hasOwn(config, type)) { attributes = attributes.filter((attr) => attr.type !== 'JSXSpreadAttribute' && !includes(config[type], propName(attr))); } diff --git a/src/rules/no-noninteractive-element-to-interactive-role.js b/src/rules/no-noninteractive-element-to-interactive-role.js index 601039aa1..57286a7e2 100644 --- a/src/rules/no-noninteractive-element-to-interactive-role.js +++ b/src/rules/no-noninteractive-element-to-interactive-role.js @@ -15,7 +15,7 @@ import { } from 'jsx-ast-utils'; import type { JSXIdentifier } from 'ast-types-flow'; import includes from 'array-includes'; -import has from 'has'; +import hasOwn from 'hasown'; import type { ESLintConfig, ESLintContext, ESLintVisitorSelectorConfig } from '../../flow/eslint'; import type { ESLintJSXAttribute } from '../../flow/eslint-jsx'; import getElementType from '../util/getElementType'; @@ -68,7 +68,7 @@ export default ({ // Allow overrides from rule configuration for specific elements and // roles. const allowedRoles = (options[0] || {}); - if (has(allowedRoles, type) && includes(allowedRoles[type], role)) { + if (hasOwn(allowedRoles, type) && includes(allowedRoles[type], role)) { return; } if ( diff --git a/src/rules/no-redundant-roles.js b/src/rules/no-redundant-roles.js index ae031a444..f624eef84 100644 --- a/src/rules/no-redundant-roles.js +++ b/src/rules/no-redundant-roles.js @@ -10,7 +10,7 @@ // ---------------------------------------------------------------------------- import includes from 'array-includes'; -import has from 'has'; +import hasOwn from 'hasown'; import type { JSXOpeningElement } from 'ast-types-flow'; import type { ESLintConfig, ESLintContext, ESLintVisitorSelectorConfig } from '../../flow/eslint'; import getElementType from '../util/getElementType'; @@ -58,7 +58,7 @@ export default ({ const allowedRedundantRoles = (options[0] || {}); let redundantRolesForElement; - if (has(allowedRedundantRoles, type)) { + if (hasOwn(allowedRedundantRoles, type)) { redundantRolesForElement = allowedRedundantRoles[type]; } else { redundantRolesForElement = DEFAULT_ROLE_EXCEPTIONS[type] || []; diff --git a/src/util/getElementType.js b/src/util/getElementType.js index 85ba853ba..c735a8052 100644 --- a/src/util/getElementType.js +++ b/src/util/getElementType.js @@ -3,7 +3,7 @@ */ import type { JSXOpeningElement } from 'ast-types-flow'; -import has from 'has'; +import hasOwn from 'hasown'; import { elementType, getProp, getLiteralPropValue } from 'jsx-ast-utils'; import type { ESLintContext } from '../../flow/eslint'; @@ -21,7 +21,7 @@ const getElementType = (context: ESLintContext): ((node: JSXOpeningElement) => s return rawType; } - return has(componentMap, rawType) ? componentMap[rawType] : rawType; + return hasOwn(componentMap, rawType) ? componentMap[rawType] : rawType; }; };