Skip to content

Commit 6f26721

Browse files
committed
replace prettier with biome
1 parent 0270ba8 commit 6f26721

File tree

6 files changed

+268
-39
lines changed

6 files changed

+268
-39
lines changed

.vscode/settings.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"javascript.validate.enable": false,
3-
"standard.enable": true,
4-
"files.eol": "\n"
3+
"files.eol": "\n",
4+
"editor.defaultFormatter": "biomejs.biome"
55
}

biome.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
3+
"organizeImports": {
4+
"enabled": true
5+
},
6+
"linter": {
7+
"enabled": true,
8+
"rules": {
9+
"recommended": true,
10+
"complexity": {
11+
"noForEach": "off"
12+
}
13+
}
14+
},
15+
"formatter": {
16+
"enabled": true,
17+
"indentStyle": "space"
18+
},
19+
"files": {
20+
"include": ["src/**", "test/**"]
21+
}
22+
}

package-lock.json

+228-22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",
77
"scripts": {
8-
"lint": "prettier --write .",
9-
"test": "npm run lint && npm run unittests",
8+
"check": "npx @biomejs/biome check --apply .",
9+
"test": "npm run check && npm run unittests",
1010
"unittests": "tsc && node --test --test-reporter spec test/*.mjs",
1111
"tdd": "npx -y watchlist --eager src test -- npm run unittests",
1212
"prepublishOnly": "tsc",
1313
"release-patch": "npx np patch",
14-
"release-beta": "npx np --tag=beta"
14+
"release-beta": "npx np --tag=beta",
15+
"release-jsr": "npx -y jsr publish"
1516
},
1617
"files": [
1718
"lib/index.js",
@@ -33,9 +34,9 @@
3334
},
3435
"homepage": "https://github.com/tolu/ISO8601-duration#readme",
3536
"devDependencies": {
37+
"@biomejs/biome": "^1.5.3",
3638
"@js-temporal/polyfill": "*",
3739
"@types/node": "^20.11.24",
38-
"prettier": "^2.6.2",
3940
"typescript": "5.3.3"
4041
}
41-
}
42+
}

src/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const parse = (durationString: string): Duration => {
6262
}
6363
// Check only one fraction is used
6464
if (slicedMatches.filter((v) => /\./.test(v || "")).length > 1) {
65-
throw new RangeError(`only the smallest unit can be fractional`);
65+
throw new RangeError("only the smallest unit can be fractional");
6666
}
6767

6868
return slicedMatches.reduce((prev, next, idx) => {
@@ -74,7 +74,7 @@ export const parse = (durationString: string): Duration => {
7474
/** Convert ISO8601 duration object to an end Date. */
7575
export const end = (
7676
durationInput: Duration,
77-
startDate: Date = new Date()
77+
startDate: Date = new Date(),
7878
): Date => {
7979
const duration = Object.assign({}, defaultDuration, durationInput);
8080

@@ -89,7 +89,7 @@ export const end = (
8989
const hoursInMs = duration.hours * 3600 * 1000;
9090
const minutesInMs = duration.minutes * 60 * 1000;
9191
then.setMilliseconds(
92-
then.getMilliseconds() + duration.seconds * 1000 + hoursInMs + minutesInMs
92+
then.getMilliseconds() + duration.seconds * 1000 + hoursInMs + minutesInMs,
9393
);
9494
// Special case weeks
9595
then.setDate(then.getDate() + duration.weeks * 7);
@@ -100,7 +100,7 @@ export const end = (
100100
/** Convert ISO8601 duration object to seconds */
101101
export const toSeconds = (
102102
durationInput: Duration,
103-
startDate: Date = new Date()
103+
startDate: Date = new Date(),
104104
): number => {
105105
const duration = Object.assign({}, defaultDuration, durationInput);
106106

@@ -111,7 +111,7 @@ export const toSeconds = (
111111
// Account for timezone offset between start and end date
112112
const tzStart = startDate.getTimezoneOffset();
113113
const tzEnd = then.getTimezoneOffset();
114-
let tzOffsetSeconds = (tzStart - tzEnd) * 60;
114+
const tzOffsetSeconds = (tzStart - tzEnd) * 60;
115115

116116
const seconds = (then.getTime() - now.getTime()) / 1000;
117117
return seconds + tzOffsetSeconds;

0 commit comments

Comments
 (0)