Skip to content

Commit e67bd92

Browse files
committed
RI-6231 - eslint fixes
1 parent 5595152 commit e67bd92

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

redisinsight/ui/src/pages/browser/modules/key-details/components/rejson-details/rejson-dynamic-types/RejsonDynamicTypes.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import RejsonDynamicTypes from './RejsonDynamicTypes'
66

77
const mockedProps = mock<DynamicTypesProps>()
88

9-
const mockedDownloadedSimpleArray = "[1, 2, 3]"
9+
const mockedDownloadedSimpleArray = '[1, 2, 3]'
1010

1111
describe('RejsonDynamicTypes Component', () => {
1212
it('renders correctly simple downloaded JSON', () => {

redisinsight/ui/src/pages/browser/modules/key-details/components/rejson-details/rejson-scalar/RejsonScalar.spec.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,17 @@ describe('JSONScalar', () => {
103103
})
104104

105105
it('should render BigInt value when root', () => {
106-
render(<RejsonScalar
106+
render(<RejsonScalar
107107
{...instance(mockedProps)}
108-
isRoot={true}
108+
isRoot
109109
value={BigInt('1188950299261208742')}
110110
/>)
111111

112112
expect(screen.getByText('1188950299261208742')).toBeInTheDocument()
113113
})
114114

115115
it('should render BigInt value when not root', () => {
116-
render(<RejsonScalar
116+
render(<RejsonScalar
117117
{...instance(mockedProps)}
118118
isRoot={false}
119119
value={BigInt('1188950299261208742')}
@@ -123,19 +123,19 @@ describe('JSONScalar', () => {
123123
})
124124

125125
it('should render regular number without n suffix', () => {
126-
render(<RejsonScalar
126+
render(<RejsonScalar
127127
{...instance(mockedProps)}
128-
isRoot={true}
128+
isRoot
129129
value={123}
130130
/>)
131131

132132
expect(screen.getByText('123')).toBeInTheDocument()
133133
})
134134

135135
it('should render string value with quotes', () => {
136-
render(<RejsonScalar
136+
render(<RejsonScalar
137137
{...instance(mockedProps)}
138-
isRoot={true}
138+
isRoot
139139
value="test"
140140
/>)
141141

redisinsight/ui/src/pages/browser/modules/key-details/components/rejson-details/utils/utils.spec.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,48 +82,48 @@ describe('JSONUtils', () => {
8282

8383
describe('JSON Parsing Utils', () => {
8484
const bigintAsString = '1188950299261208742'
85-
85+
8686
describe('parseValue', () => {
8787
it('should handle non-string values', () => {
8888
expect(parseValue(123)).toBe(123)
8989
expect(parseValue(null)).toBe(null)
9090
expect(parseValue(undefined)).toBe(undefined)
9191
})
92-
92+
9393
it('should parse typed integer values', () => {
9494
const result = parseValue(bigintAsString, 'integer')
9595
expect(typeof result).toBe('bigint')
9696
expect(result.toString()).toBe(bigintAsString)
9797
})
98-
98+
9999
it('should parse regular numbers as numbers, not bigints', () => {
100100
const result = parseValue('42', 'integer')
101101
expect(typeof result).toBe('number')
102102
expect(result).toBe(42)
103103
})
104-
104+
105105
it('should handle string type with quotes', () => {
106106
expect(parseValue('"test"', 'string')).toBe('test')
107107
expect(parseValue('test', 'string')).toBe('test')
108108
})
109-
109+
110110
it('should parse boolean values', () => {
111111
expect(parseValue('true', 'boolean')).toBe(true)
112112
expect(parseValue('false', 'boolean')).toBe(false)
113113
})
114-
114+
115115
it('should parse null values', () => {
116116
expect(parseValue('null', 'null')).toBe(null)
117117
})
118-
118+
119119
it('should parse JSON objects without type', () => {
120120
const input = `{"value": ${bigintAsString}, "text": "test"}`
121121
const result = parseValue(input)
122122
expect(typeof result.value).toBe('bigint')
123123
expect(result.value.toString()).toBe(bigintAsString)
124124
expect(result.text).toBe('test')
125125
})
126-
126+
127127
it('should parse JSON arrays without type', () => {
128128
const input = `[${bigintAsString}, "test"]`
129129
const result = parseValue(input)
@@ -132,32 +132,32 @@ describe('JSONUtils', () => {
132132
expect(result[1]).toBe('test')
133133
})
134134
})
135-
135+
136136
describe('parseJsonData', () => {
137137
it('should handle null or undefined data', () => {
138138
expect(parseJsonData(null)).toBe(null)
139139
expect(parseJsonData(undefined)).toBe(undefined)
140140
})
141-
141+
142142
it('should parse array of typed values', () => {
143143
const input = [
144144
{ type: 'string', value: '"John"' },
145145
{ type: 'integer', value: bigintAsString }
146146
]
147147
const result = parseJsonData(input)
148-
148+
149149
expect(result[0].value).toBe('John')
150150
expect(typeof result[1].value).toBe('bigint')
151151
expect(result[1].value.toString()).toBe(bigintAsString)
152152
})
153-
153+
154154
it('should preserve non-typed array items', () => {
155155
const input = [
156156
{ value: '"John"' },
157157
{ someOtherProp: 'test' }
158158
]
159159
const result = parseJsonData(input)
160-
160+
161161
expect(result[0].value).toBe('"John"')
162162
expect(result[1].someOtherProp).toBe('test')
163163
})

redisinsight/ui/src/pages/browser/modules/key-details/components/rejson-details/utils/utils.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const getBrackets = (type: string, position: 'start' | 'end' = 'start') =
6363

6464
export const isValidKey = (key: string): boolean => /^"([^"\\]|\\.)*"$/.test(key)
6565

66-
const JSONParser = JSONBigInt({
66+
const JSONParser = JSONBigInt({
6767
useNativeBigInt: true,
6868
strict: false
6969
})
@@ -88,7 +88,7 @@ export const parseValue = (value: any, type?: string): any => {
8888
return null
8989
case 'string':
9090
if (value.startsWith('"') && value.endsWith('"')) {
91-
value = value.slice(1, -1)
91+
return value.slice(1, -1)
9292
}
9393
return value
9494
default:
@@ -97,10 +97,10 @@ export const parseValue = (value: any, type?: string): any => {
9797
}
9898

9999
const parsed = JSONParser.parse(value)
100-
100+
101101
if (typeof parsed === 'object' && parsed !== null) {
102102
if (Array.isArray(parsed)) {
103-
return parsed.map(val => parseValue(val))
103+
return parsed.map((val) => parseValue(val))
104104
}
105105
const result: { [key: string]: any } = {}
106106
Object.entries(parsed).forEach(([key, val]) => {
@@ -121,11 +121,11 @@ export const parseJsonData = (data: any) => {
121121
try {
122122
if (data && Array.isArray(data)) {
123123
return data.map((item: { type?: string; value?: any }) => ({
124-
...item,
125-
value: item.type && item.value ? parseValue(item.value, item.type) : item.value
126-
}))
124+
...item,
125+
value: item.type && item.value ? parseValue(item.value, item.type) : item.value
126+
}))
127127
}
128-
128+
129129
return parseValue(data)
130130
} catch (e) {
131131
return data

0 commit comments

Comments
 (0)