Skip to content

Commit 6afe41c

Browse files
talentlessguyljharb
authored andcommitted
[Refactor] remove hasown
1 parent d4af7b1 commit 6afe41c

File tree

6 files changed

+10
-6
lines changed

6 files changed

+10
-6
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
"axobject-query": "^4.1.0",
8282
"damerau-levenshtein": "^1.0.8",
8383
"es-iterator-helpers": "^1.1.0",
84-
"hasown": "^2.0.2",
8584
"jsx-ast-utils": "^3.3.5",
8685
"language-tags": "^1.0.9",
8786
"minimatch": "^10.0.1",

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ import {
1616
propName,
1717
} from 'jsx-ast-utils';
1818
import type { JSXIdentifier } from 'ast-types-flow';
19-
import hasOwn from 'hasown';
2019
import type { ESLintConfig, ESLintContext, ESLintVisitorSelectorConfig } from '../../flow/eslint';
2120
import type { ESLintJSXAttribute } from '../../flow/eslint-jsx';
2221
import getElementType from '../util/getElementType';
2322
import isInteractiveElement from '../util/isInteractiveElement';
2423
import isNonInteractiveRole from '../util/isNonInteractiveRole';
2524
import isPresentationRole from '../util/isPresentationRole';
2625

26+
const { hasOwn } = Object;
27+
2728
const errorMessage = 'Interactive elements should not be assigned non-interactive roles.';
2829

2930
export default ({

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
propName,
1717
} from 'jsx-ast-utils';
1818
import type { JSXOpeningElement } from 'ast-types-flow';
19-
import hasOwn from 'hasown';
2019
import type { ESLintConfig, ESLintContext, ESLintVisitorSelectorConfig } from '../../flow/eslint';
2120
import { arraySchema, generateObjSchema } from '../util/schemas';
2221
import getElementType from '../util/getElementType';
@@ -29,6 +28,8 @@ import isNonInteractiveElement from '../util/isNonInteractiveElement';
2928
import isNonInteractiveRole from '../util/isNonInteractiveRole';
3029
import isPresentationRole from '../util/isPresentationRole';
3130

31+
const { hasOwn } = Object;
32+
3233
const errorMessage = 'Non-interactive elements should not be assigned mouse or keyboard event listeners.';
3334

3435
const defaultInteractiveProps = [].concat(

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ import {
1414
propName,
1515
} from 'jsx-ast-utils';
1616
import type { JSXIdentifier } from 'ast-types-flow';
17-
import hasOwn from 'hasown';
1817
import type { ESLintConfig, ESLintContext, ESLintVisitorSelectorConfig } from '../../flow/eslint';
1918
import type { ESLintJSXAttribute } from '../../flow/eslint-jsx';
2019
import getElementType from '../util/getElementType';
2120
import getExplicitRole from '../util/getExplicitRole';
2221
import isNonInteractiveElement from '../util/isNonInteractiveElement';
2322
import isInteractiveRole from '../util/isInteractiveRole';
2423

24+
const { hasOwn } = Object;
25+
2526
const errorMessage = 'Non-interactive elements should not be assigned interactive roles.';
2627

2728
export default ({

src/rules/no-redundant-roles.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
// Rule Definition
1010
// ----------------------------------------------------------------------------
1111

12-
import hasOwn from 'hasown';
1312
import type { JSXOpeningElement } from 'ast-types-flow';
1413
import type { ESLintConfig, ESLintContext, ESLintVisitorSelectorConfig } from '../../flow/eslint';
1514
import getElementType from '../util/getElementType';
1615
import getExplicitRole from '../util/getExplicitRole';
1716
import getImplicitRole from '../util/getImplicitRole';
1817

18+
const { hasOwn } = Object;
19+
1920
const errorMessage = (element, implicitRole) => (
2021
`The element ${element} has an implicit role of ${implicitRole}. Defining this explicitly is redundant and should be avoided.`
2122
);

src/util/getElementType.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
*/
44

55
import type { JSXOpeningElement } from 'ast-types-flow';
6-
import hasOwn from 'hasown';
76
import { elementType, getProp, getLiteralPropValue } from 'jsx-ast-utils';
87

98
import type { ESLintContext } from '../../flow/eslint';
109

10+
const { hasOwn } = Object;
11+
1112
const getElementType = (context: ESLintContext): ((node: JSXOpeningElement) => string) => {
1213
const { settings } = context;
1314
const polymorphicPropName = settings['jsx-a11y']?.polymorphicPropName;

0 commit comments

Comments
 (0)