Skip to content

Commit e911b81

Browse files
authored
chore: remove hasown polyfill (#19)
Part of #16.
1 parent 7ddb177 commit e911b81

8 files changed

+18
-12
lines changed

.changeset/orange-ravens-fold.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-jsx-a11y-x": patch
3+
---
4+
5+
Removes `hasOwn` polyfill and uses native functionality instead.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
"axobject-query": "^4.1.0",
5757
"damerau-levenshtein": "^1.0.8",
5858
"emoji-regex": "^9.2.2",
59-
"hasown": "^2.0.2",
6059
"jsx-ast-utils": "^3.3.5",
6160
"language-tags": "^1.0.9",
6261
"minimatch": "^3.1.2",

src/rules/no-interactive-element-to-noninteractive-role.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { dom } from 'aria-query';
1313
import { getProp, getLiteralPropValue, propName } from 'jsx-ast-utils';
1414
import type { JSXIdentifier } from 'ast-types-flow';
1515
import includes from 'array-includes';
16-
import hasOwn from 'hasown';
1716
import type {
1817
ESLintConfig,
1918
ESLintContext,
@@ -72,7 +71,10 @@ export default ({
7271
// Allow overrides from rule configuration for specific elements and
7372
// roles.
7473
const allowedRoles = options[0] || {};
75-
if (hasOwn(allowedRoles, type) && includes(allowedRoles[type], role)) {
74+
if (
75+
Object.hasOwn(allowedRoles, type) &&
76+
includes(allowedRoles[type], role)
77+
) {
7678
return;
7779
}
7880
if (

src/rules/no-noninteractive-element-interactions.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
} from 'jsx-ast-utils';
1818
import type { JSXOpeningElement } from 'ast-types-flow';
1919
import includes from 'array-includes';
20-
import hasOwn from 'hasown';
2120
import type {
2221
ESLintConfig,
2322
ESLintContext,
@@ -67,7 +66,7 @@ export default ({
6766
const config = options[0] || {};
6867
const interactiveProps = config.handlers || defaultInteractiveProps;
6968
// Allow overrides from rule configuration for specific elements and roles.
70-
if (hasOwn(config, type)) {
69+
if (Object.hasOwn(config, type)) {
7170
attributes = attributes.filter(
7271
attr =>
7372
attr.type !== 'JSXSpreadAttribute' &&

src/rules/no-noninteractive-element-to-interactive-role.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { dom } from 'aria-query';
1313
import { propName } from 'jsx-ast-utils';
1414
import type { JSXIdentifier } from 'ast-types-flow';
1515
import includes from 'array-includes';
16-
import hasOwn from 'hasown';
1716
import type {
1817
ESLintConfig,
1918
ESLintContext,
@@ -72,7 +71,10 @@ export default ({
7271
// Allow overrides from rule configuration for specific elements and
7372
// roles.
7473
const allowedRoles = options[0] || {};
75-
if (hasOwn(allowedRoles, type) && includes(allowedRoles[type], role)) {
74+
if (
75+
Object.hasOwn(allowedRoles, type) &&
76+
includes(allowedRoles[type], role)
77+
) {
7678
return;
7779
}
7880
if (

src/rules/no-redundant-roles.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
// ----------------------------------------------------------------------------
1111

1212
import includes from 'array-includes';
13-
import hasOwn from 'hasown';
1413
import type { JSXOpeningElement } from 'ast-types-flow';
1514
import type {
1615
ESLintConfig,
@@ -64,7 +63,7 @@ export default ({
6463
const allowedRedundantRoles = options[0] || {};
6564
let redundantRolesForElement;
6665

67-
if (hasOwn(allowedRedundantRoles, type)) {
66+
if (Object.hasOwn(allowedRedundantRoles, type)) {
6867
redundantRolesForElement = allowedRedundantRoles[type];
6968
} else {
7069
redundantRolesForElement = DEFAULT_ROLE_EXCEPTIONS[type] || [];

src/util/getElementType.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/** @flow */
22

33
import type { JSXOpeningElement } from 'ast-types-flow';
4-
import hasOwn from 'hasown';
54
import includes from 'array-includes';
65
import { elementType, getProp, getLiteralPropValue } from 'jsx-ast-utils';
76

@@ -33,7 +32,9 @@ const getElementType = (
3332
return rawType;
3433
}
3534

36-
return hasOwn(componentMap, rawType) ? componentMap[rawType] : rawType;
35+
return Object.hasOwn(componentMap, rawType)
36+
? componentMap[rawType]
37+
: rawType;
3738
};
3839
};
3940

yarn.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3828,7 +3828,6 @@ __metadata:
38283828
eslint-plugin-import-x: "npm:^4.11.1"
38293829
estraverse: "npm:^5.3.0"
38303830
flow-bin: "npm:^0.147.0"
3831-
hasown: "npm:^2.0.2"
38323831
hermes-eslint: "npm:^0.28.1"
38333832
in-publish: "npm:^2.0.1"
38343833
jackspeak: "npm:=2.1.1"

0 commit comments

Comments
 (0)