Skip to content

Commit 218c8bb

Browse files
authored
feat: sonarqube refactoring (#61)
1 parent ee5a8ad commit 218c8bb

17 files changed

Lines changed: 68 additions & 79 deletions

File tree

.github/workflows/chromatic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
- name: Install dependencies
2020
# 👇 Install dependencies with the same package manager used in the project (replace it as needed), e.g. yarn, npm, pnpm
21-
run: npm ci
21+
run: npm ci --ignore-scripts
2222
# 👇 Adds Chromatic as a step in the workflow
2323

2424
- name: Publish to Chromatic

.github/workflows/npm-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/checkout@v4
1212

1313
- name: Clean and Install
14-
run: npm ci
14+
run: npm ci --ignore-scripts
1515

1616
- name: Build
1717
run: npm run build

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
registry-url: 'https://registry.npmjs.org'
1919

2020
- name: Clean and Install
21-
run: npm ci
21+
run: npm ci --ignore-scripts
2222

2323
- name: Configure git
2424
run: |

Changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
# Changelog
44

5+
## v2.1.1 - SonarQube Refactoring
6+
7+
### 👾 Fix
8+
9+
- Fix multiple code smells and bugs reported by SonarQube
10+
- Improve Dropdown keyboard accessibility and semantic HTML
11+
- Order CSS imports and fix duplicate type imports
12+
- Parametrize string utility tests
13+
514
## v2.1.0 - Update Libraries
615

716
### ☝🏻 Upgrade

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"framework design",
1111
"design system"
1212
],
13-
"version": "2.1.0",
13+
"version": "2.1.1",
1414
"homepage": "https://github.com/creativecodeco/ui",
1515
"author": {
1616
"name": "John Toro",

src/theme/main.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
@import 'tailwindcss';
2-
@plugin "daisyui";
3-
42
@import './accordion.css';
53
@import './avatar.css';
64
@import './badge.css';
@@ -9,3 +7,5 @@
97
@import './radio.css';
108
@import './span.css';
119
@import './textbox.css';
10+
11+
@plugin "daisyui";

src/types/ui/components/accordion.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface AccordionType {
88
}
99

1010
export interface AccordionOption {
11+
key?: string;
1112
header: React.ReactElement;
1213
body: React.ReactElement;
1314
}

src/types/ui/components/badge.types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import type { ColorType, SizeType } from '@/types';
1+
import type { ColorType, PositionType, SizeType } from '@/types';
22
import type { IconType } from 'react-icons';
3-
import type { PositionType } from '@/types';
43

54
export interface BadgeType {
65
children: React.ReactNode;

src/types/ui/components/button.types.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import type { BadgeType, ColorButtonType, SizeType } from '@/types';
1+
import type {
2+
BadgeType,
3+
ColorButtonType,
4+
PositionType,
5+
SizeType
6+
} from '@/types';
27
import type { IconType } from 'react-icons';
3-
import type { PositionType } from '@/types';
48

59
export interface ButtonType extends React.ButtonHTMLAttributes<HTMLButtonElement> {
610
isLink?: boolean;

src/ui/components/accordion/accordion.component.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import cls from 'classnames';
22

3-
import type { AccordionType } from '@/types';
3+
import type { AccordionOption, AccordionType } from '@/types';
4+
5+
const getOptionKey = (option: AccordionOption, index: number): string => {
6+
return option.key || `accordion-item-${index}`;
7+
};
48

59
const Accordion = ({
610
name,
@@ -16,17 +20,19 @@ const Accordion = ({
1620
'gap-2': !join
1721
})}
1822
>
19-
{options.map(({ header, body }, index) => (
23+
{options.map((option, index) => (
2024
<div
21-
key={index}
25+
key={getOptionKey(option, index)}
2226
className={cls('collapse bg-base-200', {
2327
[`accordion-type-${iconType}`]: iconType,
2428
'join-item border border-base-300': join
2529
})}
2630
>
2731
<input type={multiple ? 'checkbox' : 'radio'} name={name} />
28-
<div className='collapse-title text-xl font-medium'>{header}</div>
29-
<div className='collapse-content'>{body}</div>
32+
<div className='collapse-title text-xl font-medium'>
33+
{option.header}
34+
</div>
35+
<div className='collapse-content'>{option.body}</div>
3036
</div>
3137
))}
3238
</div>

0 commit comments

Comments
 (0)