Skip to content

Commit 398f172

Browse files
committed
fix PR comments
1 parent 622e268 commit 398f172

3 files changed

Lines changed: 8 additions & 14 deletions

File tree

packages/eslint-plugin/src/rules/a11y/consistent_is_invalid_props.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
import { type TSESTree, ESLintUtils } from '@typescript-eslint/utils';
2121
import { getAttrValue } from '../../utils/get_attr_value';
22-
import { isAttrsEqual } from "../../utils/is_attrs_equal";
22+
import { areAttrsEqual } from '../../utils/are_attrs_equal';
23+
2324
const formControlComponent = 'EuiFormRow';
2425

2526
const formControlChildComponents = [
@@ -74,7 +75,7 @@ export const ConsistentIsInvalidProps = ESLintUtils.RuleCreator.withoutDocs({
7475
'isInvalid'
7576
);
7677

77-
if (!isAttrsEqual(childIsInvalid,formRowIsInvalid)) {
78+
if (!areAttrsEqual(childIsInvalid, formRowIsInvalid)) {
7879
const componentName = (
7980
childElement.openingElement.name as TSESTree.JSXIdentifier
8081
).name;

packages/eslint-plugin/src/rules/a11y/sr_output_disabled_tooltip.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import { type TSESTree, ESLintUtils } from '@typescript-eslint/utils';
1010
import { getAttrValue } from '../../utils/get_attr_value';
11-
import { isAttrsEqual } from '../../utils/is_attrs_equal';
11+
import { areAttrsEqual } from '../../utils/are_attrs_equal';
1212

1313
const tooltipComponent = 'EuiToolTip';
1414
const disabledTooltipComponentProp = 'disableScreenReaderOutput';
@@ -65,7 +65,7 @@ export const ScreenReaderOutputDisabledTooltip =
6565
if (
6666
tooltipContent &&
6767
ariaLabel &&
68-
isAttrsEqual(tooltipContent,ariaLabel)
68+
areAttrsEqual(tooltipContent, ariaLabel)
6969
) {
7070
const buttonElementName = (
7171
buttonElement.openingElement.name as TSESTree.JSXIdentifier

packages/eslint-plugin/src/utils/is_attrs_equal.ts renamed to packages/eslint-plugin/src/utils/are_attrs_equal.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,7 @@
1919

2020
const normalizeAttrString = (str?: string) => str?.trim().replace(/\s+/g, ' ');
2121

22-
export const isAttrsEqual = (...strings: Array<string | undefined>): boolean => {
23-
if (strings.length < 2) return true;
24-
25-
const normalizedStrings = strings.map(normalizeAttrString);
26-
const firstValue = normalizedStrings[0];
27-
28-
return normalizedStrings.every((value) => {
29-
if (value === undefined && firstValue === undefined) return true;
30-
return value === firstValue;
31-
});
22+
export const areAttrsEqual = (...strings: Array<string | undefined>): boolean => {
23+
const [first, ...rest] = strings.map(normalizeAttrString);
24+
return rest.every((s) => s === first);
3225
};

0 commit comments

Comments
 (0)