Skip to content

Commit 8eda1d7

Browse files
authored
Create custom error type with properties (#25)
1 parent 5a83cd3 commit 8eda1d7

File tree

10 files changed

+350
-66
lines changed

10 files changed

+350
-66
lines changed

.eslintrc.cjs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
module.exports = {
2-
settings: {
3-
jest: {
4-
version: 28,
5-
},
6-
},
72
env: {
83
es2022: true,
94
node: true,

biome.json

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.1/schema.json",
3+
"formatter": {
4+
"enabled": true,
5+
"indentStyle": "space"
6+
},
7+
"files": {
8+
"ignore": ["dist"]
9+
},
10+
"organizeImports": {
11+
"enabled": false
12+
},
13+
"linter": {
14+
"enabled": true,
15+
"rules": {
16+
"recommended": true,
17+
"complexity": {
18+
"noExtraBooleanCast": "error",
19+
"noMultipleSpacesInRegularExpressionLiterals": "error",
20+
"noUselessCatch": "error",
21+
"noUselessSwitchCase": "off",
22+
"useOptionalChain": "off"
23+
},
24+
"a11y": {
25+
"useKeyWithClickEvents": "off",
26+
"noAutofocus": "off",
27+
"noSvgWithoutTitle": "off"
28+
},
29+
"performance": {
30+
"noDelete": "off"
31+
},
32+
"correctness": {
33+
"noConstAssign": "error",
34+
"noConstantCondition": "error",
35+
"noEmptyCharacterClassInRegex": "error",
36+
"noEmptyPattern": "error",
37+
"noGlobalObjectCalls": "error",
38+
"noInvalidConstructorSuper": "error",
39+
"noNewSymbol": "error",
40+
"noNonoctalDecimalEscape": "error",
41+
"noPrecisionLoss": "error",
42+
"noUnknownFunction": "off",
43+
"noUnusedImports": "warn",
44+
"noSelfAssign": "error",
45+
"useExhaustiveDependencies": "warn",
46+
"noSetterReturn": "error",
47+
"noSwitchDeclarations": "error",
48+
"noUndeclaredVariables": "error",
49+
"noUnsafeOptionalChaining": "error",
50+
"useIsNan": "error",
51+
"useValidForDirection": "error",
52+
"useYield": "error"
53+
},
54+
"style": {
55+
"noNonNullAssertion": "off",
56+
"noRestrictedGlobals": {
57+
"level": "error",
58+
"options": {
59+
"deniedGlobals": [
60+
"location",
61+
"event",
62+
"name",
63+
"alert",
64+
"confirm",
65+
"self",
66+
"top",
67+
"history"
68+
]
69+
}
70+
},
71+
"noParameterAssign": "off",
72+
"noUselessElse": "off",
73+
"useConst": "off"
74+
},
75+
"security": {
76+
"noDangerouslySetInnerHtml": "off"
77+
},
78+
"suspicious": {
79+
"noAssignInExpressions": "off",
80+
"noDuplicateSelectorsKeyframeBlock": "off",
81+
"noExplicitAny": "off",
82+
"noArrayIndexKey": "off"
83+
}
84+
}
85+
},
86+
"overrides": [
87+
{
88+
"include": ["*.test.*", "test/**/*"],
89+
"linter": {
90+
"rules": {
91+
"style": {
92+
"noNonNullAssertion": "off"
93+
},
94+
"suspicious": {
95+
"noImplicitAnyLet": "off"
96+
}
97+
}
98+
}
99+
}
100+
],
101+
"javascript": {
102+
"formatter": {
103+
"trailingCommas": "es5"
104+
},
105+
"globals": ["React", "JSX", "Deno"]
106+
}
107+
}

deno-bootstrap/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"lock": false}
1+
{ "lock": false }

deno-bootstrap/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ const scriptType = Deno.args[1];
33
const script = Deno.args[2];
44

55
const importURL =
6-
scriptType == "import"
6+
scriptType === "import"
77
? script
8-
: "data:text/tsx," + encodeURIComponent(script);
8+
: `data:text/tsx,${encodeURIComponent(script)}`;
99

1010
const mod = await import(importURL);
1111
if (!mod.default) {
@@ -17,11 +17,11 @@ if (typeof mod.default.fetch !== "function") {
1717

1818
const onError =
1919
mod.default.onError ??
20-
function (error: unknown) {
20+
((error: unknown) => {
2121
console.error(error);
2222
return new Response("Internal Server Error", { status: 500 });
23-
};
24-
const onListen = mod.default.onListen ?? function (_localAddr: Deno.NetAddr) {};
23+
});
24+
const onListen = mod.default.onListen ?? ((_localAddr: Deno.NetAddr) => {});
2525

2626
// Use an empty onListen callback to prevent Deno from logging
2727
const server = Deno.serve(

package-lock.json

Lines changed: 165 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313
"build": "tsc --build",
1414
"prepare": "npm run lint && npm run build"
1515
},
16-
"files": [
17-
"dist",
18-
"deno-bootstrap"
19-
],
16+
"files": ["dist", "deno-bootstrap"],
2017
"repository": {
2118
"type": "git",
2219
"url": "git+https://github.com/val-town/deno-http-worker.git"
@@ -32,11 +29,12 @@
3229
},
3330
"homepage": "https://github.com/val-town/deno-http-worker#readme",
3431
"devDependencies": {
32+
"@biomejs/biome": "^1.9.4",
33+
"@types/eslint": "^8.44.4",
3534
"@types/node": "^20.12.7",
36-
"eslint": "^8.57.0",
3735
"@typescript-eslint/eslint-plugin": "^7.8.0",
36+
"eslint": "^8.57.0",
3837
"eslint-plugin-import": "^2.29.1",
39-
"@types/eslint": "^8.44.4",
4038
"typescript": "^5.4.5",
4139
"vitest": "^2"
4240
}

0 commit comments

Comments
 (0)