Skip to content

Commit 82a16a2

Browse files
authored
fix(37027): Improve code quality (#1210)
* fix(37009): Prefer `Number.parseInt` over `parseInt` * fix(37009): Use `new Array()` instead of `Array()`. * fix(37009): Provide a compare function to avoid sorting elements alphabetically. * fix(37009): Use `new Error()` instead of `Error()`. * fix(37009): Prefer `Number.isNaN` over `isNaN`. * fix(37009): Prefer `String#replaceAll()` over `String#replace()`. * fix(37009): Correct one of the identical sub-expressions on both sides of operator "&&" * fix(37009): A fragment with only one child is redundant. * fix(37009): Consider removing 'undefined' type or '?' specifier, one of them is redundant. * fix(37009): Use `export…from` to re-export * fix(37009): Prefer using an optional chain expression instead, as it's more concise and easier to read * chore(37009): try fixing the CI check * chore(37009): try fixing the CI check * chore(37009): try fixing the CI check (2) * chore(37009): try fixing the CI check (3) * chore(37009): try fixing the CI check (4) * chore(37009): try fixing the CI check (4) * chore(37009): try fixing the CI check (4) * chore(37009): cypress summary * Revert "chore(37009): cypress summary" This reverts commit bc81fb9. * fix(37009): fix condition * test(37009): add tests
1 parent 9546c76 commit 82a16a2

File tree

36 files changed

+143
-147
lines changed

36 files changed

+143
-147
lines changed

.github/workflows/check.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ jobs:
5656
- 'hivemq-edge-openapi/**'
5757
- '.github/**'
5858
59+
- name: Debug openapi-changed output
60+
run: |
61+
echo "openapi-changed: ${{ steps.frontend.outputs.changed }}"
62+
63+
5964
check-openapi:
6065
needs: check-for-changes
6166
uses: ./.github/workflows/check-openapi.yml

hivemq-edge-frontend/cypress/utils/datahub.utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ export const cy_checkDataPolicyGraph = () => {
4545

4646
const areArraysIdentical = (a: string[], b: string[]): boolean => {
4747
if (a.length !== b.length) return false
48-
const sortedA = [...a].sort()
49-
const sortedB = [...b].sort()
48+
const sortedA = [...a].sort((a, b) => a.localeCompare(b))
49+
const sortedB = [...b].sort((a, b) => a.localeCompare(b))
5050
return sortedA.every((val, idx) => val === sortedB[idx])
5151
}
5252

hivemq-edge-frontend/src/__test-utils__/color.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ export const hexToRgb = (hex: string, asString = false) => {
1010
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
1111
const format = result
1212
? {
13-
r: parseInt(result[1], 16),
14-
g: parseInt(result[2], 16),
15-
b: parseInt(result[3], 16),
13+
r: Number.parseInt(result[1], 16),
14+
g: Number.parseInt(result[2], 16),
15+
b: Number.parseInt(result[3], 16),
1616
}
1717
: null
1818
if (!format) return null

hivemq-edge-frontend/src/__test-utils__/rjsf/rjsf.mocks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { ArrayFieldItemTemplate } from '@/components/rjsf/ArrayFieldItemTemplate
1212

1313
interface RjsfMocksProps {
1414
schema: RJSFSchema
15-
uiSchema?: UiSchema | undefined
15+
uiSchema?: UiSchema
1616
onSubmit?: (data: IChangeEvent, event: FormEvent) => void
1717
onError?: (errors: RJSFValidationError[]) => void
1818
formData?: unknown

hivemq-edge-frontend/src/api/hooks/useEvents/__handlers__/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const contentType = [
4343
]
4444

4545
export const mockEdgeEvent = (n = maxEvents): Event[] =>
46-
Array.from(Array(n), (_, x) => ({
46+
Array.from(new Array(n), (_, x) => ({
4747
identifier: makeID(TypeIdentifier.type.EVENT, x),
4848

4949
severity: severityKeys[x % severityKeys.length] as Event.severity,

hivemq-edge-frontend/src/api/hooks/useGetMetrics/__handlers__/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const MOCK_METRIC_SAMPLE: DataPoint = {
6666
value: 50000,
6767
}
6868

69-
export const MOCK_METRIC_SAMPLE_ARRAY: DataPoint[] = Array.from(Array(10), (_, x) => ({
69+
export const MOCK_METRIC_SAMPLE_ARRAY: DataPoint[] = Array.from(new Array(10), (_, x) => ({
7070
sampleTime: DateTime.fromISO(MOCK_METRIC_SAMPLE.sampleTime as string)
7171
.plus({ hour: x })
7272
.toISO(),
Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
import { TbArrowsJoin, TbArrowsShuffle } from 'react-icons/tb'
2-
import { MdOutlineCloudDone, MdOutlineCloudOff } from 'react-icons/md'
3-
import { WorkspaceIcon } from './TopicIcon.tsx'
4-
import { PulseAgentIcon } from './PulseAgentIcon.tsx'
5-
6-
export {
7-
TbArrowsJoin as HqCombiner,
8-
TbArrowsShuffle as HqAssets,
9-
MdOutlineCloudDone as HqPulseActivated,
10-
MdOutlineCloudOff as HqPulseNotActivated,
11-
WorkspaceIcon,
12-
PulseAgentIcon,
13-
}
1+
export { TbArrowsJoin as HqCombiner, TbArrowsShuffle as HqAssets } from 'react-icons/tb'
2+
export { MdOutlineCloudDone as HqPulseActivated, MdOutlineCloudOff as HqPulseNotActivated } from 'react-icons/md'
3+
export { WorkspaceIcon } from './TopicIcon.tsx'
4+
export { PulseAgentIcon } from './PulseAgentIcon.tsx'

hivemq-edge-frontend/src/components/PaginatedTable/PaginatedTable.spec.cy.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const MOCK_COLUMN: ColumnDef<MOCK_TYPE>[] = [
2020
]
2121

2222
const MOCK_DATA = (n: number): MOCK_TYPE[] =>
23-
Array.from(Array(n), (_, x) => ({
23+
Array.from(new Array(n), (_, x) => ({
2424
column1: `item ${x}`,
2525
column2: n - x,
2626
}))

hivemq-edge-frontend/src/components/WarningMessage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import DefaultLogo from '@/assets/app/bridge-empty.svg'
44

55
interface WarningMessageProps extends HTMLChakraProps<'div'> {
66
title?: string
7-
image?: string | undefined
7+
image?: string
88
prompt: string
99
alt: string
1010
}

hivemq-edge-frontend/src/components/rjsf/ArrayFieldItemTemplate.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export const ArrayFieldItemTemplate: FC<ArrayFieldTemplateItemType> = (props) =>
5858

5959
const { isOpen, onToggle, getButtonProps, getDisclosureProps, onOpen } = useDisclosure({
6060
defaultIsOpen:
61-
!collapsableItems ||
6261
!collapsableItems?.titleKey ||
6362
(index === props.totalItems - 1 && children.props.formData[collapsableItems?.titleKey] === undefined),
6463
})

0 commit comments

Comments
 (0)