File tree Expand file tree Collapse file tree
packages/eslint-plugin/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919
2020import { type TSESTree , ESLintUtils } from '@typescript-eslint/utils' ;
2121import { getAttrValue } from '../../utils/get_attr_value' ;
22- import { isAttrsEqual } from "../../utils/is_attrs_equal" ;
22+ import { areAttrsEqual } from '../../utils/are_attrs_equal' ;
23+
2324const formControlComponent = 'EuiFormRow' ;
2425
2526const 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 ;
Original file line number Diff line number Diff line change 88
99import { type TSESTree , ESLintUtils } from '@typescript-eslint/utils' ;
1010import { getAttrValue } from '../../utils/get_attr_value' ;
11- import { isAttrsEqual } from '../../utils/is_attrs_equal ' ;
11+ import { areAttrsEqual } from '../../utils/are_attrs_equal ' ;
1212
1313const tooltipComponent = 'EuiToolTip' ;
1414const 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
Original file line number Diff line number Diff line change 1919
2020const 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} ;
You can’t perform that action at this time.
0 commit comments