From 177791ae5d03fa80f2dcc433dfa86bd2d95b688f Mon Sep 17 00:00:00 2001 From: maojunxyz Date: Fri, 8 Aug 2025 18:27:13 +0800 Subject: [PATCH] fix: Fix ESLint errors in JSONRepair files - Fix trailing spaces in JSONRepair.mjs - Convert single quotes to double quotes in test files - Fix line ending style (CRLF to LF) - All lint checks now pass --- src/core/operations/JSONRepair.mjs | 2 +- tests/operations/tests/JSONRepair.mjs | 28 +++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/core/operations/JSONRepair.mjs b/src/core/operations/JSONRepair.mjs index 852ca8d3..65eacdf7 100644 --- a/src/core/operations/JSONRepair.mjs +++ b/src/core/operations/JSONRepair.mjs @@ -38,7 +38,7 @@ class JSONRepair extends Operation { // Dynamic import of jsonrepair to handle potential module loading issues const { jsonrepair } = await import("jsonrepair"); return jsonrepair(input); - + } catch (err) { throw new OperationError("Unable to repair JSON. The input contains errors that cannot be automatically fixed.\n" + err.message); } diff --git a/tests/operations/tests/JSONRepair.mjs b/tests/operations/tests/JSONRepair.mjs index 46768df9..9b88bad0 100644 --- a/tests/operations/tests/JSONRepair.mjs +++ b/tests/operations/tests/JSONRepair.mjs @@ -22,8 +22,8 @@ TestRegister.addTests([ }, { name: "JSON Repair: valid JSON unchanged", - input: '{"name": "John", "age": 30}', - expectedOutput: '{"name": "John", "age": 30}', + input: "{\"name\": \"John\", \"age\": 30}", + expectedOutput: "{\"name\": \"John\", \"age\": 30}", recipeConfig: [ { op: "JSON Repair", @@ -33,8 +33,8 @@ TestRegister.addTests([ }, { name: "JSON Repair: missing quotes around keys", - input: '{name: "John", age: 30}', - expectedOutput: '{"name": "John", "age": 30}', + input: "{name: \"John\", age: 30}", + expectedOutput: "{\"name\": \"John\", \"age\": 30}", recipeConfig: [ { op: "JSON Repair", @@ -45,7 +45,7 @@ TestRegister.addTests([ { name: "JSON Repair: single quotes to double quotes", input: "{'name': 'John', 'age': 30}", - expectedOutput: '{"name": "John", "age": 30}', + expectedOutput: "{\"name\": \"John\", \"age\": 30}", recipeConfig: [ { op: "JSON Repair", @@ -55,8 +55,8 @@ TestRegister.addTests([ }, { name: "JSON Repair: trailing comma in object", - input: '{"name": "John", "age": 30,}', - expectedOutput: '{"name": "John", "age": 30}', + input: "{\"name\": \"John\", \"age\": 30,}", + expectedOutput: "{\"name\": \"John\", \"age\": 30}", recipeConfig: [ { op: "JSON Repair", @@ -66,8 +66,8 @@ TestRegister.addTests([ }, { name: "JSON Repair: trailing comma in array", - input: '[1, 2, 3,]', - expectedOutput: '[1, 2, 3]', + input: "[1, 2, 3,]", + expectedOutput: "[1, 2, 3]", recipeConfig: [ { op: "JSON Repair", @@ -77,8 +77,8 @@ TestRegister.addTests([ }, { name: "JSON Repair: Python constants", - input: '{"active": True, "data": None, "flag": False}', - expectedOutput: '{"active": true, "data": null, "flag": false}', + input: "{\"active\": True, \"data\": None, \"flag\": False}", + expectedOutput: "{\"active\": true, \"data\": null, \"flag\": false}", recipeConfig: [ { op: "JSON Repair", @@ -143,7 +143,7 @@ TestRegister.addTests([ { name: "JSON Repair: complex mixed issues", input: `{ - name: 'John', // Person's name + name: "John", // Person's name age: 30, active: True, data: None, @@ -163,8 +163,8 @@ TestRegister.addTests([ }, { name: "JSON Repair: JSONP notation", - input: 'callback({"name": "John", "age": 30})', - expectedOutput: '{"name": "John", "age": 30}', + input: "callback({\"name\": \"John\", \"age\": 30})", + expectedOutput: "{\"name\": \"John\", \"age\": 30}", recipeConfig: [ { op: "JSON Repair",