Skip to content

Commit b859444

Browse files
committed
lint & format
1 parent d295796 commit b859444

File tree

8 files changed

+134
-16
lines changed

8 files changed

+134
-16
lines changed

.vscode/extensions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": ["biomejs.biome", "mikestead.dotenv", "EditorConfig.EditorConfig"],
3+
"unwantedRecommendations": [
4+
// we use Biome for linting and formatting so we don't need these
5+
"dbaeumer.vscode-eslint",
6+
"esbenp.prettier-vscode"
7+
]
8+
}

.vscode/settings.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
{
22
"typescript.tsdk": "node_modules/typescript/lib",
33
"typescript.enablePromptUseWorkspaceTsdk": true,
4-
"typescript.preferences.importModuleSpecifier": "non-relative"
4+
"typescript.preferences.importModuleSpecifier": "non-relative",
5+
"editor.formatOnSave": true,
6+
"editor.codeActionsOnSave": {
7+
"quickfix.biome": true,
8+
"source.fixAll.biome": true,
9+
"source.organizeImports.biome": true
10+
},
11+
"editor.defaultFormatter": "biomejs.biome",
12+
"[json]": {
13+
"editor.defaultFormatter": "biomejs.biome"
14+
},
15+
"[jsonc]": {
16+
"editor.defaultFormatter": "biomejs.biome"
17+
},
18+
"[typescript]": {
19+
"editor.defaultFormatter": "biomejs.biome"
20+
},
21+
"[javascript]": {
22+
"editor.defaultFormatter": "biomejs.biome"
23+
}
524
}

biome.json

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.3.3/schema.json",
3+
"vcs": {
4+
"root": ".",
5+
"enabled": true,
6+
"clientKind": "git"
7+
},
8+
"files": {
9+
"include": [
10+
"./**/*.ts",
11+
"./**/*.js",
12+
"./**/*.cjs",
13+
"./**/*.d.ts",
14+
"./**/*.json",
15+
"./**/*.jsonc"
16+
],
17+
"ignoreUnknown": true,
18+
"ignore": ["node_modules", ".lagon", "_"]
19+
},
20+
"organizeImports": {
21+
"enabled": false
22+
},
23+
"formatter": {
24+
"enabled": true,
25+
"lineWidth": 100,
26+
"indentWidth": 2,
27+
"indentStyle": "space",
28+
"formatWithErrors": true,
29+
"include": [
30+
"./**/*.ts",
31+
"./**/*.js",
32+
"./**/*.cjs",
33+
"./**/*.d.ts",
34+
"./**/*.json",
35+
"./**/*.jsonc"
36+
]
37+
},
38+
"linter": {
39+
"enabled": true,
40+
"rules": {
41+
"all": true,
42+
"style": {
43+
"useBlockStatements": "off",
44+
"useSelfClosingElements": "off",
45+
"noUnusedTemplateLiteral": "off"
46+
},
47+
"nursery": {
48+
"all": true,
49+
"noUnusedImports": "off"
50+
},
51+
"complexity": {
52+
"useLiteralKeys": "off"
53+
},
54+
"correctness": {
55+
"noUndeclaredVariables": "off"
56+
},
57+
"suspicious": {
58+
"noRedeclare": "off",
59+
"noExplicitAny": "off",
60+
"noEmptyInterface": "off"
61+
}
62+
}
63+
},
64+
"json": {
65+
"parser": {
66+
"allowComments": true
67+
},
68+
"formatter": {
69+
"enabled": true,
70+
"lineWidth": 100,
71+
"indentWidth": 2
72+
}
73+
},
74+
"javascript": {
75+
"parser": {
76+
"unsafeParameterDecoratorsEnabled": true
77+
},
78+
"formatter": {
79+
"enabled": true,
80+
"lineWidth": 100,
81+
"indentWidth": 2,
82+
"indentStyle": "space",
83+
"quoteStyle": "single",
84+
"trailingComma": "none",
85+
"semicolons": "asNeeded",
86+
"jsxQuoteStyle": "single",
87+
"quoteProperties": "asNeeded",
88+
"arrowParentheses": "asNeeded"
89+
}
90+
}
91+
}

bun.lockb

2.64 KB
Binary file not shown.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@
99
"dev": "lagon dev --env='.env.dev'",
1010
"build": "lagon build",
1111
"deploy:preview": "lagon deploy",
12-
"deploy": "lagon deploy --production"
12+
"deploy": "lagon deploy --production",
13+
"lint": "biome check --apply .",
14+
"format": "biome format . --write",
15+
"typecheck": "tsc --project tsconfig.json --noEmit"
1316
},
1417
"dependencies": {
1518
"graphql": "^16.8.1"
1619
},
1720
"devDependencies": {
21+
"@biomejs/biome": "^1.3.3",
1822
"bun-types": "^1.0.13",
1923
"typescript": "^5.2.2"
2024
},

src/graphql/schema.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
printSchema,
33
buildClientSchema,
44
getIntrospectionQuery,
5-
type IntrospectionOptions,
5+
type IntrospectionOptions
66
} from 'graphql'
77
import type { Json } from '#/types.ts'
88

@@ -14,24 +14,24 @@ export function jsonSchemaToSDL(jsonString: string) {
1414

1515
export async function fetchJsonSchema({
1616
url,
17-
minimal = true,
17+
minimal = true
1818
}: {
1919
url: string
2020
minimal?: boolean
2121
}): Promise<Json> {
2222
const introspectionOptions = {
2323
descriptions: !minimal,
2424
directiveIsRepeatable: !minimal,
25-
schemaDescription: !minimal,
25+
schemaDescription: !minimal
2626
} satisfies IntrospectionOptions
2727
try {
2828
const response = await fetch(url, {
2929
method: 'POST',
3030
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
3131
body: JSON.stringify({
3232
query: getIntrospectionQuery(introspectionOptions),
33-
variable: {},
34-
}),
33+
variable: {}
34+
})
3535
})
3636

3737
if (!response.ok) throw new Error(`Failed to fetch from ${url}: ${response.statusText}`)

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export async function handler(request: Request): Promise<Response> {
3131
const { htmlPage } = await import('#/graphql/graphiql.html.ts')
3232
return new Response(htmlPage({ endpoint: introspectionURL }), {
3333
status: 200,
34-
headers: { 'Content-Type': 'text/html' },
34+
headers: { 'Content-Type': 'text/html' }
3535
})
3636
}
3737

@@ -42,13 +42,13 @@ export async function handler(request: Request): Promise<Response> {
4242

4343
return new Response(sdlSchema, {
4444
status: sdlSchema.startsWith('Encountered an error') ? 400 : 200,
45-
headers: { 'Content-Type': 'text/plain' },
45+
headers: { 'Content-Type': 'text/plain' }
4646
})
4747
}
4848

4949
return new Response(JSON.stringify(jsonSchema), {
5050
status: 200,
51-
headers: { 'Content-Type': 'application/json' },
51+
headers: { 'Content-Type': 'application/json' }
5252
})
5353
} catch (error) {
5454
const message = error instanceof Error ? error.message : `Encountered an error: ${error}`

src/utilities.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export const BASE_URL = process.env.BASE_URL ?? 'https://introspect.lagon.dev'
22

33
export const EXAMPLE_GRAPHQL_URL = 'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3'
44

5-
export const LANDING_MESSAGE = /* md */`
5+
export const LANDING_MESSAGE = /* md */ `
66
If you want a JSON GraphQL schema, the format is:
77
${BASE_URL}/json/<introspection-url>
88
@@ -20,11 +20,7 @@ Source code: https://github.com/o-az/introspect
2020
`
2121

2222
export function isURL(str: string) {
23-
try {
24-
return !!new URL(str)
25-
} catch {
26-
return false
27-
}
23+
return !!new URL(str)
2824
}
2925

3026
export function formatMessages(...messages: string[]) {

0 commit comments

Comments
 (0)