Skip to content

Commit 2267caa

Browse files
chore: add a prettier config and reformat files
1 parent 282f249 commit 2267caa

File tree

6 files changed

+22
-8
lines changed

6 files changed

+22
-8
lines changed

.prettierrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"printWidth": 320,
3+
"tabWidth": 2,
4+
"overrides": [
5+
{
6+
"files": ["src/**/*.ts", "tests/**/*.js"],
7+
"options": {
8+
"tabWidth": 4
9+
}
10+
}
11+
]
12+
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@
3131
"scripts": {
3232
"build": "tsc",
3333
"coverage": "vitest run --coverage",
34+
"format": "prettier --write .",
3435
"test": "vitest",
3536
"test:ui": "vitest --ui"
3637
},
3738
"devDependencies": {
3839
"@vitest/coverage-istanbul": "^1.2.2",
3940
"@vitest/ui": "^1.2.2",
41+
"prettier": "^3.3.3",
4042
"typescript": "^5.3.3",
4143
"vitest": "^1.2.2"
4244
}

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Allow } from "./options";
22
export * from "./options";
33

4-
class PartialJSON extends Error { }
4+
class PartialJSON extends Error {}
55

6-
class MalformedJSON extends Error { }
6+
class MalformedJSON extends Error {}
77

88
/**
99
* Parse incomplete JSON
@@ -21,7 +21,7 @@ function parseJSON(jsonString: string, allowPartial: number = Allow.ALL): any {
2121
throw new Error(`${jsonString} is empty`);
2222
}
2323
return _parseJSON(jsonString.trim(), allowPartial);
24-
};
24+
}
2525

2626
const _parseJSON = (jsonString: string, allow: number) => {
2727
const length = jsonString.length;
@@ -152,7 +152,7 @@ const _parseJSON = (jsonString: string, allow: number) => {
152152
if (Allow.NUM & allow)
153153
try {
154154
return JSON.parse(jsonString.substring(0, jsonString.lastIndexOf("e")));
155-
} catch (e) { }
155+
} catch (e) {}
156156
throwMalformedError(String(e));
157157
}
158158
}

src/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const ATOM = STR | NUM | SPECIAL;
5656
export const COLLECTION = ARR | OBJ;
5757
export const ALL = ATOM | COLLECTION;
5858

59-
/**
59+
/**
6060
* Control what types you allow to be partially parsed.
6161
* The default is to allow all types to be partially parsed, which in most casees is the best option.
6262
* @example

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"forceConsistentCasingInFileNames": true,
1313
"strict": true
1414
}
15-
}
15+
}

vitest.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { defineConfig } from "vitest/config"
1+
import { defineConfig } from "vitest/config";
22

33
export default defineConfig({
44
test: {
55
coverage: {
66
provider: "istanbul",
77
},
88
},
9-
})
9+
});

0 commit comments

Comments
 (0)