Skip to content

Commit 7754859

Browse files
committed
Fixed issues from rebase
1 parent 9e09a31 commit 7754859

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

lib/util/ruleFactory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ export function hasAccessibleLabel(
8989
const allowTextContentChild = !!config.allowTextContentChild;
9090

9191
if (allowFieldParent && hasFieldParent(context)) return true;
92-
if (requiredProps?.every(p => hasDefinedProp(node.attributes, p))) return true;
93-
if (labelProps?.some(p => hasNonEmptyProp(node.attributes, p))) return true;
92+
if (requiredProps?.every(p => hasDefinedProp(opening.attributes, p))) return true;
93+
if (labelProps?.some(p => hasNonEmptyProp(opening.attributes, p))) return true;
9494
if (allowWrappingLabel && isInsideLabelTag(context)) return true;
9595
if (allowHtmlFor && hasAssociatedLabelViaHtmlFor(opening, context)) return true;
9696
if (allowLabelledBy && hasAssociatedLabelViaAriaLabelledBy(opening, context)) return true;

tests/lib/rules/utils/ruleFactory.test.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
import type { TSESLint, TSESTree } from "@typescript-eslint/utils";
45
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
6+
import { Rule, RuleTester } from "eslint";
57

8+
import { hasDefinedProp } from "../../../../lib/util/hasDefinedProp";
9+
import { hasFieldParent } from "../../../../lib/util/hasFieldParent";
10+
import { hasLabeledChild } from "../../../../lib/util/hasLabeledChild";
611
import { hasNonEmptyProp } from "../../../../lib/util/hasNonEmptyProp";
12+
import { hasTextContentChild } from "../../../../lib/util/hasTextContentChild";
13+
import { hasToolTipParent } from "../../../../lib/util/hasTooltipParent";
714
import {
15+
hasAssociatedLabelViaAriaDescribedby,
816
hasAssociatedLabelViaAriaLabelledBy,
9-
isInsideLabelTag,
1017
hasAssociatedLabelViaHtmlFor,
11-
hasAssociatedLabelViaAriaDescribedby
18+
isInsideLabelTag
1219
} from "../../../../lib/util/labelUtils";
13-
import { hasFieldParent } from "../../../../lib/util/hasFieldParent";
1420
import { hasAccessibleLabel, LabeledControlConfig, makeLabeledControlRule } from "../../../../lib/util/ruleFactory";
15-
import type { TSESLint, TSESTree } from "@typescript-eslint/utils";
16-
import { Rule, RuleTester } from "eslint";
17-
import { hasLabeledChild } from "../../../../lib/util/hasLabeledChild";
18-
import { hasToolTipParent } from "../../../../lib/util/hasTooltipParent";
19-
import { hasTextContentChild } from "../../../../lib/util/hasTextContentChild";
2021

2122
jest.mock("../../../../lib/util/hasDefinedProp", () => ({
2223
hasDefinedProp: jest.fn()
2324
}));
25+
26+
jest.mock("../../../../lib/util/hasNonEmptyProp", () => ({
27+
hasNonEmptyProp: jest.fn()
28+
}));
2429
jest.mock("../../../../lib/util/labelUtils", () => ({
2530
hasAssociatedLabelViaAriaDescribedby: jest.fn(),
2631
hasAssociatedLabelViaAriaLabelledBy: jest.fn(),
@@ -36,8 +41,6 @@ jest.mock("../../../../lib/util/hasLabeledChild", () => ({
3641
jest.mock("../../../../lib/util/hasTooltipParent", () => ({
3742
hasToolTipParent: jest.fn()
3843
}));
39-
40-
import { hasDefinedProp } from "../../../../lib/util/hasDefinedProp";
4144
jest.mock("../../../../lib/util/hasTextContentChild", () => ({
4245
hasTextContentChild: jest.fn()
4346
}));

0 commit comments

Comments
 (0)