Skip to content

Commit

Permalink
chore: add biome
Browse files Browse the repository at this point in the history
  • Loading branch information
lishaduck committed Dec 11, 2024
1 parent f767c32 commit cd7cfb8
Show file tree
Hide file tree
Showing 14 changed files with 267 additions and 54 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/deno.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:
name: Deploy
runs-on: ubuntu-latest

permissions:
pull-requests: write # Needed for biome comments

steps:
- name: 📚 Git checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand All @@ -44,6 +47,8 @@ jobs:
with:
deno-version: ${{ env.DENO_VERSION }}
- name: 📦 Cache dependencies
run: deno install --frozen
run: deno install --frozen --allow-scripts=npm:@biomejs/[email protected]
- name: 🕵️ Run linter, verify formatting, typecheck
run: deno task ci
- name: 🔨 Build
run: deno task build
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"recommendations": [
"denoland.vscode-deno",
"bradlc.vscode-tailwindcss"
"bradlc.vscode-tailwindcss",
"biomejs.biome"
]
}
31 changes: 19 additions & 12 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
{
"deno.enable": true,
"deno.lint": true,
"editor.defaultFormatter": "denoland.vscode-deno",
"[typescriptreact]": {
"editor.defaultFormatter": "denoland.vscode-deno"
"editor.defaultFormatter": "biomejs.biome",
"[typescript][typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
"[javascript][javascriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[javascriptreact]": {
"editor.defaultFormatter": "denoland.vscode-deno"
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[javascript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
"[css]": {
"editor.defaultFormatter": "biomejs.biome"
},
"css.customData": [
".vscode/tailwind.json"
]
"editor.codeActionsOnSave": {
"quickfix.biome": "always",
"source.organizeImports.biome": "always"
},
"css.customData": [".vscode/tailwind.json"],
"tailwindCSS.experimental.classRegex": [
"tw`([^`]*)",
["tw\\(([^\\)]*)\\)", "`([^`]*)`"]
],
"cSpell.words": ["Preact"]
}
62 changes: 62 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "deno",
"command": "task",
"problemMatcher": ["$deno"],
"label": "deno task: dev",
"detail": "Run the server in development mode",
"args": ["dev"],
"group": {
"kind": "build"
},
"icon": {
"color": "terminal.ansiGreen",
"id": "wrench"
},
},
{
"type": "deno",
"command": "task",
"problemMatcher": ["$deno"],
"label": "deno task: start",
"detail": "Run the server",
"args": ["start"],
"group": {
"kind": "build",
"isDefault": true
},
"icon": {
"color": "terminal.ansiWhite",
"id": "server"
},
"runOptions": {
"runOn": "folderOpen",
"instanceLimit": 1
},
"promptOnClose": false,
"presentation": {
"reveal": "silent",
"panel": "dedicated",
"showReuseMessage": false,
"clear": true
}
},
{
"type": "deno",
"command": "task",
"problemMatcher": ["$deno"],
"label": "deno task: build",
"detail": "Build the website",
"args": ["build"],
"group": {
"kind": "build"
},
"icon": {
"color": "terminal.ansiBlue",
"id": "gear"
},
},
]
}
64 changes: 64 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"organizeImports": {
"enabled": true
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"formatWithErrors": true
},
"linter": {
"enabled": true,
"rules": {
"all": true,
"nursery": {
"all": true,
"noHeadElement": "off",
"noImgElement": "off",
"noNestedTernary": "off",
"useComponentExportOnlyModules": "off",
"useConsistentCurlyBraces": "off",
"useExplicitType": "off",
"useImportRestrictions": "off"
},
"style": {
"noDefaultExport": "off",
"noImplicitBoolean": "off",
"useDefaultSwitchClause": "off",
"useFilenamingConvention": "off",
"useNamingConvention": "off"
},
"complexity": {
"useLiteralKeys": "off"
},
"suspicious": {
"noConsole": {
"level": "warn",
"options": {
"allow": ["error", "info", "warn"]
}
},
"noReactSpecificProps": "off"
},
"correctness": {
"noUndeclaredDependencies": "off"
},
"a11y": {
"noLabelWithoutControl": "off"
}
}
},
"vcs": {
"enabled": true,
"useIgnoreFile": true,
"clientKind": "git",
"defaultBranch": "main"
},
"files": {
"ignore": [".vscode/*.json"]
},
"javascript": {
"globals": ["Deno"]
}
}
6 changes: 3 additions & 3 deletions components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import type { ComponentChildren } from "preact";
import type { ComponentChildren, JSX } from "preact";

export interface ButtonProps {
onClick?: () => void;
children?: ComponentChildren;
disabled?: boolean;
}

export function Button(props: ButtonProps) {
export function Button(props: ButtonProps): JSX.Element {
return (
<button
{...props}
class="px-2 py-1 border-gray-500 border-2 rounded bg-white hover:bg-gray-200 transition-colors"
class="rounded border-2 border-gray-500 bg-white px-2 py-1 transition-colors hover:bg-gray-200"
/>
);
}
59 changes: 36 additions & 23 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,58 @@
{
"nodeModulesDir": "auto",
"tasks": {
"check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
"check": {
"command": "sleep 0",
"dependencies": ["format", "lint", "typecheck"]
},
"format": "biome format --write",
"format:check": "biome format",
"lint": {
"command": "sleep 0",
"dependencies": ["lint:deno", "lint:biome"]
},
"lint:deno": "deno lint",
"lint:biome": "biome check --error-on-warnings",
"ci": {
"command": "sleep 0",
"dependencies": ["lint:deno", "ci:biome", "typecheck"]
},
"ci:biome": "biome ci --error-on-warnings",
"typecheck": "deno check -q **/*.ts **/*.tsx",
"dev": "deno run -A --watch=static/,routes/ dev.ts",
"build": "deno run -A dev.ts build",
"start": "deno run -A main.ts",
"update": "deno run -A -r jsr:@fresh/update ."
},
"lint": {
"rules": {
"tags": [
"fresh",
"recommended"
"tags": ["fresh"],
"include": [
"ban-untagged-todo",
"explicit-module-boundary-types",
"guard-for-in",
"no-await-in-loop",
"no-external-import",
"no-implicit-declare-namespace-export",
"no-non-null-asserted-optional-chain",
"no-sync-fn-in-async-fn",
"no-throw-literal"
]
}
},
"exclude": [
"**/_fresh/*"
],
"exclude": ["**/_fresh/*"],
"imports": {
"fresh": "jsr:@fresh/core@^2.0.0-alpha.26",
"@biomejs/biome": "npm:@biomejs/biome@^1.9.4",
"@fresh/plugin-tailwind": "jsr:@fresh/plugin-tailwind@^0.0.1-alpha.7",
"preact": "npm:preact@^10.25.1",
"@preact/signals": "npm:@preact/signals@^1.3.1",
"fresh": "jsr:@fresh/core@^2.0.0-alpha.26",
"preact": "npm:preact@^10.25.1",
"tailwindcss": "npm:tailwindcss@^3.4.16"
},
"compilerOptions": {
"lib": [
"dom",
"dom.asynciterable",
"dom.iterable",
"deno.ns"
],
"lib": ["dom", "dom.asynciterable", "dom.iterable", "deno.ns"],
"jsx": "precompile",
"jsxImportSource": "preact",
"jsxPrecompileSkipElements": [
"a",
"img",
"source",
"body",
"html",
"head"
]
"jsxPrecompileSkipElements": ["a", "img", "source", "body", "html", "head"]
}
}
49 changes: 49 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cd7cfb8

Please sign in to comment.