Skip to content

Commit

Permalink
chore: add a prettier config and reformat files
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 committed Sep 17, 2024
1 parent 282f249 commit 2267caa
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
12 changes: 12 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"printWidth": 320,
"tabWidth": 2,
"overrides": [
{
"files": ["src/**/*.ts", "tests/**/*.js"],
"options": {
"tabWidth": 4
}
}
]
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@
"scripts": {
"build": "tsc",
"coverage": "vitest run --coverage",
"format": "prettier --write .",
"test": "vitest",
"test:ui": "vitest --ui"
},
"devDependencies": {
"@vitest/coverage-istanbul": "^1.2.2",
"@vitest/ui": "^1.2.2",
"prettier": "^3.3.3",
"typescript": "^5.3.3",
"vitest": "^1.2.2"
}
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Allow } from "./options";
export * from "./options";

class PartialJSON extends Error { }
class PartialJSON extends Error {}

class MalformedJSON extends Error { }
class MalformedJSON extends Error {}

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

const _parseJSON = (jsonString: string, allow: number) => {
const length = jsonString.length;
Expand Down Expand Up @@ -152,7 +152,7 @@ const _parseJSON = (jsonString: string, allow: number) => {
if (Allow.NUM & allow)
try {
return JSON.parse(jsonString.substring(0, jsonString.lastIndexOf("e")));
} catch (e) { }
} catch (e) {}
throwMalformedError(String(e));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const ATOM = STR | NUM | SPECIAL;
export const COLLECTION = ARR | OBJ;
export const ALL = ATOM | COLLECTION;

/**
/**
* Control what types you allow to be partially parsed.
* The default is to allow all types to be partially parsed, which in most casees is the best option.
* @example
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"forceConsistentCasingInFileNames": true,
"strict": true
}
}
}
4 changes: 2 additions & 2 deletions vitest.config.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { defineConfig } from "vitest/config"
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
coverage: {
provider: "istanbul",
},
},
})
});

1 comment on commit 2267caa

@vercel
Copy link

@vercel vercel bot commented on 2267caa Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.