chore: update deps and apply lint
All checks were successful
/ deploy_site (push) Successful in 22s

This commit is contained in:
2025-03-19 15:10:18 +09:00
parent b01a3696a0
commit f78c9cd655
5 changed files with 659 additions and 604 deletions

View File

@ -2,21 +2,25 @@ import { Transform } from './Transform'
const pythonToJSON = (pythonStr: string): string => {
// Validate basic structure first before any replacements
if (!(/^\s*(?:\{[\s\S]*\}|\[[\s\S]*\])\s*$/.test(pythonStr))) {
if (!/^\s*(?:\{[\s\S]*\}|\[[\s\S]*\])\s*$/.test(pythonStr)) {
throw new Error('Invalid Python dictionary or array format')
}
// Perform all replacements in a single pass
return pythonStr
.replace(/('|None\b|True\b|False\b)/g, match => {
switch (match) {
case "'": return '"'
case 'None': return 'null'
case 'True': return 'true'
case 'False': return 'false'
default: return match
}
})
return pythonStr.replace(/('|None\b|True\b|False\b)/g, (match) => {
switch (match) {
case "'":
return '"'
case 'None':
return 'null'
case 'True':
return 'true'
case 'False':
return 'false'
default:
return match
}
})
}
export const PythonDictToJSONTransform: Transform = {
@ -36,18 +40,25 @@ export const JSONToPythonDictTransform: Transform = {
fn: async (v) => {
try {
// Validate and format in one step
return JSON.stringify(JSON.parse(v), null, 2)
.replace(/("|\bnull\b|\btrue\b|\bfalse\b)/g, match => {
return JSON.stringify(JSON.parse(v), null, 2).replace(
/("|\bnull\b|\btrue\b|\bfalse\b)/g,
(match) => {
switch (match) {
case '"': return "'"
case 'null': return 'None'
case 'true': return 'True'
case 'false': return 'False'
default: return match
case '"':
return "'"
case 'null':
return 'None'
case 'true':
return 'True'
case 'false':
return 'False'
default:
return match
}
})
}
)
} catch {
throw new Error('Invalid JSON format')
}
}
}
}

View File

@ -3,10 +3,7 @@ import {
Base64EncodeTransform
} from './Base64Transforms'
import { DatetimeTransform } from './DatetimeTransforms'
import {
GzipCompressTransform,
GzipDecompressTransform
} from './GzipTransform'
import { GzipCompressTransform, GzipDecompressTransform } from './GzipTransform'
import {
JSONBeautifyTransform,
JSONEscapeTransform,

1
src/vite-env.d.ts vendored
View File

@ -1,6 +1,5 @@
/// <reference types="vite/client" />
module 'strtime' {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function strptime(string, string): Date
}