Skip to content

Commit

Permalink
Merge pull request #17 from RuiOkazaki/chore/#14-setup-biome
Browse files Browse the repository at this point in the history
Biome.jsのセットアップ
  • Loading branch information
RuiOkazaki authored Aug 25, 2024
2 parents 4635366 + 8c277cb commit 99b0cfe
Show file tree
Hide file tree
Showing 26 changed files with 306 additions and 191 deletions.
50 changes: 25 additions & 25 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
Expand All @@ -19,63 +19,63 @@ module.exports = {
commonjs: true,
es6: true,
},
ignorePatterns: ["!**/.server", "!**/.client"],
ignorePatterns: ['!**/.server', '!**/.client'],

// Base config
extends: ["eslint:recommended"],
extends: ['eslint:recommended'],

overrides: [
// React
{
files: ["**/*.{js,jsx,ts,tsx}"],
plugins: ["react", "jsx-a11y"],
files: ['**/*.{js,jsx,ts,tsx}'],
plugins: ['react', 'jsx-a11y'],
extends: [
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended",
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended',
],
settings: {
react: {
version: "detect",
version: 'detect',
},
formComponents: ["Form"],
formComponents: ['Form'],
linkComponents: [
{ name: "Link", linkAttribute: "to" },
{ name: "NavLink", linkAttribute: "to" },
{ name: 'Link', linkAttribute: 'to' },
{ name: 'NavLink', linkAttribute: 'to' },
],
"import/resolver": {
'import/resolver': {
typescript: {},
},
},
},

// Typescript
{
files: ["**/*.{ts,tsx}"],
plugins: ["@typescript-eslint", "import"],
parser: "@typescript-eslint/parser",
files: ['**/*.{ts,tsx}'],
plugins: ['@typescript-eslint', 'import'],
parser: '@typescript-eslint/parser',
settings: {
"import/internal-regex": "^~/",
"import/resolver": {
'import/internal-regex': '^~/',
'import/resolver': {
node: {
extensions: [".ts", ".tsx"],
extensions: ['.ts', '.tsx'],
},
typescript: {
alwaysTryTypes: true,
},
},
},
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
],
},

// Node
{
files: [".eslintrc.cjs"],
files: ['.eslintrc.cjs'],
env: {
node: true,
},
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: CI
on:
push:
jobs:
CI:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
- name: Install dependencies
run: bun install
- name: Run Check
run: bun run check
21 changes: 21 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[javascriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"editor.codeActionsOnSave": {
"quickfix.biome": "always",
"source.organizeImports.biome": "always"
},
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true,
"files.autoSave": "onFocusChange"
}
8 changes: 4 additions & 4 deletions app/entry.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
* For more information, see https://remix.run/file-conventions/entry.client
*/

import { RemixBrowser } from "@remix-run/react";
import { startTransition, StrictMode } from "react";
import { hydrateRoot } from "react-dom/client";
import { RemixBrowser } from '@remix-run/react';
import { StrictMode, startTransition } from 'react';
import { hydrateRoot } from 'react-dom/client';

startTransition(() => {
hydrateRoot(
document,
<StrictMode>
<RemixBrowser />
</StrictMode>
</StrictMode>,
);
});
22 changes: 12 additions & 10 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* For more information, see https://remix.run/file-conventions/entry.server
*/

import type { AppLoadContext, EntryContext } from "@remix-run/cloudflare";
import { RemixServer } from "@remix-run/react";
import { isbot } from "isbot";
import { renderToReadableStream } from "react-dom/server";
import type { AppLoadContext, EntryContext } from '@remix-run/cloudflare';
import { RemixServer } from '@remix-run/react';
import { isbot } from 'isbot';
import { renderToReadableStream } from 'react-dom/server';

export default async function handleRequest(
request: Request,
Expand All @@ -17,27 +17,29 @@ export default async function handleRequest(
// This is ignored so we can keep it in the template for visibility. Feel
// free to delete this parameter in your app if you're not using it!
// eslint-disable-next-line @typescript-eslint/no-unused-vars
loadContext: AppLoadContext
_loadContext: AppLoadContext,
) {
let finalStatusCode = responseStatusCode;

const body = await renderToReadableStream(
<RemixServer context={remixContext} url={request.url} />,
{
signal: request.signal,
onError(error: unknown) {
// Log streaming rendering errors from inside the shell
console.error(error);
responseStatusCode = 500;
finalStatusCode = 500;
},
}
},
);

if (isbot(request.headers.get("user-agent") || "")) {
if (isbot(request.headers.get('user-agent') || '')) {
await body.allReady;
}

responseHeaders.set("Content-Type", "text/html");
responseHeaders.set('Content-Type', 'text/html');
return new Response(body, {
headers: responseHeaders,
status: responseStatusCode,
status: finalStatusCode,
});
}
2 changes: 1 addition & 1 deletion app/libs/drizzle/client.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { drizzle } from "drizzle-orm/d1";
import { drizzle } from 'drizzle-orm/d1';

export const getDBClient = (d1: D1Database) => {
const db = drizzle(d1, { logger: import.meta.env.DEV });
Expand Down
32 changes: 14 additions & 18 deletions app/libs/drizzle/schema.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import { sql } from "drizzle-orm";
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
import { sql } from 'drizzle-orm';
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core';

export const users = sqliteTable("users", {
id: integer("id").primaryKey(),
provider: text("provider").notNull(),
providerId: text("provider_id").notNull().unique(),
name: text("name").notNull(),
icon: text("icon"),
createdAt: text("created_at")
.notNull()
.default(sql`(current_timestamp)`),
export const users = sqliteTable('users', {
id: integer('id').primaryKey(),
provider: text('provider').notNull(),
providerId: text('provider_id').notNull().unique(),
name: text('name').notNull(),
icon: text('icon'),
createdAt: text('created_at').notNull().default(sql`(current_timestamp)`),
});

export const posts = sqliteTable("posts", {
id: integer("id").primaryKey(),
body: text("body"),
userId: integer("user_id").references(() => users.id),
createdAt: text("created_at")
.notNull()
.default(sql`(current_timestamp)`),
export const posts = sqliteTable('posts', {
id: integer('id').primaryKey(),
body: text('body'),
userId: integer('user_id').references(() => users.id),
createdAt: text('created_at').notNull().default(sql`(current_timestamp)`),
});
10 changes: 5 additions & 5 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import {
Outlet,
Scripts,
ScrollRestoration,
} from "@remix-run/react";
import "./tailwind.css";
} from '@remix-run/react';
import './tailwind.css';

export function Layout({ children }: { children: React.ReactNode }) {
return (
<html lang="ja">
<html lang='ja'>
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charSet='utf-8' />
<meta name='viewport' content='width=device-width, initial-scale=1' />
<Meta />
<Links />
</head>
Expand Down
Loading

0 comments on commit 99b0cfe

Please sign in to comment.