diff --git a/packages/eslint-plugin/changelogs/upcoming/8920.md b/packages/eslint-plugin/changelogs/upcoming/8920.md
new file mode 100644
index 00000000000..48e812554b5
--- /dev/null
+++ b/packages/eslint-plugin/changelogs/upcoming/8920.md
@@ -0,0 +1 @@
+- Fixed attributes comparison issue in the `consistent-is-invalid-props` rule.
diff --git a/packages/eslint-plugin/src/rules/a11y/consistent_is_invalid_props.test.ts b/packages/eslint-plugin/src/rules/a11y/consistent_is_invalid_props.test.ts
index 55aa3fc07e7..eae83d3e37f 100644
--- a/packages/eslint-plugin/src/rules/a11y/consistent_is_invalid_props.test.ts
+++ b/packages/eslint-plugin/src/rules/a11y/consistent_is_invalid_props.test.ts
@@ -45,6 +45,18 @@ ruleTester.run('consistent-is-invalid-props', ConsistentIsInvalidProps, {
`,
languageOptions,
},
+ {
+ code: dedent`
+ const MyComponent = () => (
+
+
+
+ )
+ `,
+ languageOptions,
+ },
{
code: dedent`
const MyComponent = () => (
diff --git a/packages/eslint-plugin/src/rules/a11y/consistent_is_invalid_props.ts b/packages/eslint-plugin/src/rules/a11y/consistent_is_invalid_props.ts
index 6b8fa267f81..b860004ef0e 100644
--- a/packages/eslint-plugin/src/rules/a11y/consistent_is_invalid_props.ts
+++ b/packages/eslint-plugin/src/rules/a11y/consistent_is_invalid_props.ts
@@ -19,6 +19,8 @@
import { type TSESTree, ESLintUtils } from '@typescript-eslint/utils';
import { getAttrValue } from '../../utils/get_attr_value';
+import { areAttrsEqual } from '../../utils/are_attrs_equal';
+
const formControlComponent = 'EuiFormRow';
const formControlChildComponents = [
@@ -73,7 +75,7 @@ export const ConsistentIsInvalidProps = ESLintUtils.RuleCreator.withoutDocs({
'isInvalid'
);
- if (childIsInvalid !== formRowIsInvalid) {
+ if (!areAttrsEqual(childIsInvalid, formRowIsInvalid)) {
const componentName = (
childElement.openingElement.name as TSESTree.JSXIdentifier
).name;
diff --git a/packages/eslint-plugin/src/rules/a11y/sr_output_disabled_tooltip.ts b/packages/eslint-plugin/src/rules/a11y/sr_output_disabled_tooltip.ts
index fb0c64445bf..eb53cd77608 100644
--- a/packages/eslint-plugin/src/rules/a11y/sr_output_disabled_tooltip.ts
+++ b/packages/eslint-plugin/src/rules/a11y/sr_output_disabled_tooltip.ts
@@ -8,13 +8,12 @@
import { type TSESTree, ESLintUtils } from '@typescript-eslint/utils';
import { getAttrValue } from '../../utils/get_attr_value';
+import { areAttrsEqual } from '../../utils/are_attrs_equal';
const tooltipComponent = 'EuiToolTip';
const disabledTooltipComponentProp = 'disableScreenReaderOutput';
const buttonComponents = ['EuiButtonIcon'];
-const normalizeAttrString = (str?: string) => str?.trim().replace(/\s+/g, ' ');
-
export const ScreenReaderOutputDisabledTooltip =
ESLintUtils.RuleCreator.withoutDocs({
create(context) {
@@ -66,7 +65,7 @@ export const ScreenReaderOutputDisabledTooltip =
if (
tooltipContent &&
ariaLabel &&
- normalizeAttrString(tooltipContent) === normalizeAttrString(ariaLabel)
+ areAttrsEqual(tooltipContent, ariaLabel)
) {
const buttonElementName = (
buttonElement.openingElement.name as TSESTree.JSXIdentifier
diff --git a/packages/eslint-plugin/src/utils/are_attrs_equal.ts b/packages/eslint-plugin/src/utils/are_attrs_equal.ts
new file mode 100644
index 00000000000..d40e5d19390
--- /dev/null
+++ b/packages/eslint-plugin/src/utils/are_attrs_equal.ts
@@ -0,0 +1,25 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+const normalizeAttrString = (str?: string) => str?.trim().replace(/\s+/g, ' ');
+
+export const areAttrsEqual = (...strings: Array): boolean => {
+ const [first, ...rest] = strings.map(normalizeAttrString);
+ return rest.every((s) => s === first);
+};