From 9bbe753fc44c7c861a0690e8a1d3f4b53f3e75af Mon Sep 17 00:00:00 2001 From: Bisirat Amanuel Date: Fri, 22 Mar 2024 00:29:05 -0500 Subject: [PATCH 1/4] Don't generate `aria-describedby` when `helperText` & `errorMessage` are omitted. --- src/components/Form/Wrapper/InputWrapper/InputWrapper.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Form/Wrapper/InputWrapper/InputWrapper.tsx b/src/components/Form/Wrapper/InputWrapper/InputWrapper.tsx index d0373a239..db48b6acc 100644 --- a/src/components/Form/Wrapper/InputWrapper/InputWrapper.tsx +++ b/src/components/Form/Wrapper/InputWrapper/InputWrapper.tsx @@ -93,7 +93,7 @@ const InputWrapperComponent: ForwardRefRenderFunction = ( }} ref={inputProps?.ref || input} aria-labelledby={labelId} - aria-describedby={error ? errorId : helperId} + aria-describedby={error ? errorId : helperText ? helperId : undefined} onChange={onChange} onFocus={e => { onFocus?.(e); From 6c866f9371c10cbe4ebc4741030eb4fe005a31f1 Mon Sep 17 00:00:00 2001 From: Bisirat Amanuel Date: Fri, 22 Mar 2024 01:00:44 -0500 Subject: [PATCH 2/4] Fix sonar code smell --- src/components/Form/Wrapper/InputWrapper/InputWrapper.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/Form/Wrapper/InputWrapper/InputWrapper.tsx b/src/components/Form/Wrapper/InputWrapper/InputWrapper.tsx index db48b6acc..077ef5e43 100644 --- a/src/components/Form/Wrapper/InputWrapper/InputWrapper.tsx +++ b/src/components/Form/Wrapper/InputWrapper/InputWrapper.tsx @@ -64,6 +64,9 @@ const InputWrapperComponent: ForwardRefRenderFunction = ( inputWrapperClasses.push(inputProps?.wrapperProps?.className); disabled && inputWrapperClasses.push(classes["disabled"]); + const describedByErrorId = error ? errorId : undefined; + const describedByHelperId = helperText ? helperId : undefined; + return ( = ( }} ref={inputProps?.ref || input} aria-labelledby={labelId} - aria-describedby={error ? errorId : helperText ? helperId : undefined} + aria-describedby={describedByErrorId ?? describedByHelperId} onChange={onChange} onFocus={e => { onFocus?.(e); From acc3dc410e0389378f4a6b05413801a5631e0f83 Mon Sep 17 00:00:00 2001 From: Bisirat Amanuel Date: Fri, 22 Mar 2024 08:31:09 -0500 Subject: [PATCH 3/4] Replace back-slashes to forward-slashe in styles-inject import statements This issue happens on windows because path command returns system dependent paths. Performing replaceAll on the result is alternative to using `path.posix` on all uses of `path` functions. --- rollup.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index d1e83fb93..7cf36581b 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -54,7 +54,7 @@ const baseConfig = { ); file.code = file.code.replace( /import\s?(\w+)?\s?from\s?["'](\.\.\/|\.\/){1,5}node_modules\/style-inject\/dist\/style-inject.es.(esm).?js["'];?/, - `import $1 from "${relativePath}";` + `import $1 from "${relativePath.replaceAll('\\', '/')}";` ); } else if (fileName.match(/.*(.module.cjs.js)$/)) { // Replace tslib import with a custom resolution or code snippet @@ -64,7 +64,7 @@ const baseConfig = { ); file.code = file.code.replace( /require\(["'](\.\.\/|\.\/){1,5}node_modules\/style-inject\/dist\/style-inject.es.(cjs).?js["']\);?/, - `require("${relativePath}");` + `require("${relativePath.replaceAll('\\', '/')}");` ); } }); From 8eb0f0948f051f02bfbc2cd9c731d77f23eb2c1c Mon Sep 17 00:00:00 2001 From: Bisirat Amanuel Date: Fri, 22 Mar 2024 09:01:25 -0500 Subject: [PATCH 4/4] Change single quote to double quote in lint command to work on windows --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4347e38be..6824e4444 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "build-storybook": "storybook build", "chromatic": "chromatic --exit-zero-on-changes", "dev": "npm-run-all -p start test:watch storybook", - "lint": "eslint '**/*.{ts,tsx}'", + "lint": "eslint \"**/*.{ts,tsx}\"", "prepare": "husky install && rollup -c", "size": "size-limit", "start": "rollup -c -w",