Skip to content

Commit c455ffb

Browse files
committed
The one where biome replaces eslint
1 parent 39b959d commit c455ffb

34 files changed

Lines changed: 14052 additions & 16405 deletions

.eslintrc.cjs

Lines changed: 0 additions & 82 deletions
This file was deleted.

.github/workflows/validate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
useLockFile: false
3535

3636
- name: 🔬 Lint
37-
run: npm run lint:strict
37+
run: npm run lint:ci
3838

3939
typecheck:
4040
name: 🔎 Type check

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npm run typecheck && npm run lint:strict
1+
npm run typecheck && npm run lint

.prettierignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.vscode/extensions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"recommendations": ["codeforge.remix-forge"]
2+
"recommendations": ["codeforge.remix-forge", "biomejs.biome"]
33
}

.vscode/settings.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"editor.defaultFormatter": "biomejs.biome",
3+
"editor.formatOnSave": true,
4+
"editor.formatOnType": false,
5+
"editor.renderWhitespace": "all",
6+
"editor.rulers": [120, 160],
7+
"editor.codeActionsOnSave": {
8+
"source.fixAll": "always",
9+
"source.organizeImports": "never",
10+
"source.organizeImports.biome": "always",
11+
"quickfix.biome": "always"
12+
},
13+
"eslint.enable": false,
14+
"prettier.enable": false,
15+
"editor.insertSpaces": false,
16+
"editor.detectIndentation": false,
17+
"editor.tabSize": 2,
18+
"editor.trimAutoWhitespace": true,
19+
"workbench.colorCustomizations": {
20+
"editorWhitespace.foreground": "#333"
21+
},
22+
"files.trimTrailingWhitespace": true,
23+
"files.trimTrailingWhitespaceInRegexAndStrings": true,
24+
"files.trimFinalNewlines": true,
25+
"[yaml]": {
26+
"editor.defaultFormatter": "redhat.vscode-yaml"
27+
}
28+
}

app/entry.client.tsx

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
1-
import { RemixBrowser } from "@remix-run/react";
2-
import { startTransition, StrictMode } from "react";
3-
import { hydrateRoot } from "react-dom/client";
4-
import i18n from "~/localization/i18n";
5-
import i18next from "i18next";
6-
import { I18nextProvider, initReactI18next } from "react-i18next";
7-
import LanguageDetector from "i18next-browser-languagedetector";
8-
import Backend from "i18next-http-backend";
9-
import { getInitialNamespaces } from "remix-i18next/client";
10-
import { resources } from "./localization/resource";
1+
import { RemixBrowser } from "@remix-run/react"
2+
import i18next from "i18next"
3+
import LanguageDetector from "i18next-browser-languagedetector"
4+
import Backend from "i18next-http-backend"
5+
import { StrictMode, startTransition } from "react"
6+
import { hydrateRoot } from "react-dom/client"
7+
import { I18nextProvider, initReactI18next } from "react-i18next"
8+
import { getInitialNamespaces } from "remix-i18next/client"
9+
import i18n from "~/localization/i18n"
10+
import { resources } from "./localization/resource"
1111

1212
async function hydrate() {
13-
// eslint-disable-next-line import/no-named-as-default-member
14-
await i18next
15-
.use(initReactI18next) // Tell i18next to use the react-i18next plugin
16-
.use(LanguageDetector) // Setup a client-side language detector
17-
.use(Backend) // Setup your backend
18-
.init({
19-
...i18n, // spread the configuration
20-
// This function detects the namespaces your routes rendered while SSR use
21-
ns: getInitialNamespaces(),
22-
backend: { loadPath: "/locales/{{lng}}/{{ns}}.json" },
23-
resources,
24-
detection: {
25-
// Here only enable htmlTag detection, we'll detect the language only
26-
// server-side with remix-i18next, by using the `<html lang>` attribute
27-
// we can communicate to the client the language detected server-side
28-
order: ["htmlTag"],
29-
// Because we only use htmlTag, there's no reason to cache the language
30-
// on the browser, so we disable it
31-
caches: [],
32-
},
33-
});
13+
// eslint-disable-next-line import/no-named-as-default-member
14+
await i18next
15+
.use(initReactI18next) // Tell i18next to use the react-i18next plugin
16+
.use(LanguageDetector) // Setup a client-side language detector
17+
.use(Backend) // Setup your backend
18+
.init({
19+
...i18n, // spread the configuration
20+
// This function detects the namespaces your routes rendered while SSR use
21+
ns: getInitialNamespaces(),
22+
backend: { loadPath: "/locales/{{lng}}/{{ns}}.json" },
23+
resources,
24+
detection: {
25+
// Here only enable htmlTag detection, we'll detect the language only
26+
// server-side with remix-i18next, by using the `<html lang>` attribute
27+
// we can communicate to the client the language detected server-side
28+
order: ["htmlTag"],
29+
// Because we only use htmlTag, there's no reason to cache the language
30+
// on the browser, so we disable it
31+
caches: [],
32+
},
33+
})
3434

35-
startTransition(() => {
36-
hydrateRoot(
37-
document,
38-
<I18nextProvider i18n={i18next}>
39-
<StrictMode>
40-
<RemixBrowser />
41-
</StrictMode>
42-
</I18nextProvider>
43-
);
44-
});
35+
startTransition(() => {
36+
hydrateRoot(
37+
document,
38+
<I18nextProvider i18n={i18next}>
39+
<StrictMode>
40+
<RemixBrowser />
41+
</StrictMode>
42+
</I18nextProvider>
43+
)
44+
})
4545
}
4646

4747
if (window.requestIdleCallback) {
48-
window.requestIdleCallback(hydrate);
48+
window.requestIdleCallback(hydrate)
4949
} else {
50-
// Safari doesn't support requestIdleCallback
51-
// https://caniuse.com/requestidlecallback
52-
window.setTimeout(hydrate, 1);
50+
// Safari doesn't support requestIdleCallback
51+
// https://caniuse.com/requestidlecallback
52+
window.setTimeout(hydrate, 1)
5353
}

app/entry.server.tsx

Lines changed: 64 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,79 @@
1-
import { PassThrough } from "stream";
2-
import type { EntryContext } from "@remix-run/node";
3-
import { Response } from "@remix-run/web-fetch";
4-
import { RemixServer } from "@remix-run/react";
5-
import { isbot } from "isbot";
6-
import { renderToPipeableStream } from "react-dom/server";
7-
import { createInstance } from "i18next";
8-
import i18next from "./localization/i18n.server";
9-
import { I18nextProvider, initReactI18next } from "react-i18next";
10-
import Backend from "i18next-fs-backend";
11-
import i18n from "./localization/i18n"; // your i18n configuration file
12-
import { resolve } from "node:path";
13-
import { resources, returnLanguageIfSupported } from "./localization/resource";
1+
import { resolve } from "node:path"
2+
import { PassThrough } from "node:stream"
3+
import type { EntryContext } from "@remix-run/node"
4+
import { RemixServer } from "@remix-run/react"
5+
import { Response } from "@remix-run/web-fetch"
6+
import { createInstance } from "i18next"
7+
import Backend from "i18next-fs-backend"
8+
import { isbot } from "isbot"
9+
import { renderToPipeableStream } from "react-dom/server"
10+
import { I18nextProvider, initReactI18next } from "react-i18next"
11+
import i18n from "./localization/i18n" // your i18n configuration file
12+
import i18next from "./localization/i18n.server"
13+
import { resources, returnLanguageIfSupported } from "./localization/resource"
1414

15-
const ABORT_DELAY = 5000;
15+
const ABORT_DELAY = 5000
1616

1717
export default async function handleRequest(
18-
request: Request,
19-
responseStatusCode: number,
20-
responseHeaders: Headers,
21-
remixContext: EntryContext
18+
request: Request,
19+
responseStatusCode: number,
20+
responseHeaders: Headers,
21+
remixContext: EntryContext
2222
) {
23-
const url = new URL(request.url);
24-
const { pathname } = url;
23+
const url = new URL(request.url)
24+
const { pathname } = url
2525

26-
const lang = pathname.split("/")[1];
27-
const callbackName = isbot(request.headers.get("user-agent"))
28-
? "onAllReady"
29-
: "onShellReady";
26+
const lang = pathname.split("/")[1]
27+
const callbackName = isbot(request.headers.get("user-agent")) ? "onAllReady" : "onShellReady"
3028

31-
const instance = createInstance();
32-
const lng =
33-
returnLanguageIfSupported(lang) ?? (await i18next.getLocale(request));
34-
const ns = i18next.getRouteNamespaces(remixContext);
29+
const instance = createInstance()
30+
const lng = returnLanguageIfSupported(lang) ?? (await i18next.getLocale(request))
31+
const ns = i18next.getRouteNamespaces(remixContext)
3532

36-
await instance
37-
.use(initReactI18next) // Tell our instance to use react-i18next
38-
.use(Backend) // Setup our backend
39-
.init({
40-
...i18n, // spread the configuration
41-
lng, // The locale we detected above
42-
ns, // The namespaces the routes about to render wants to use
43-
backend: { loadPath: resolve("./public/locales/{{lng}}/{{ns}}.json") },
44-
resources,
45-
});
33+
await instance
34+
.use(initReactI18next) // Tell our instance to use react-i18next
35+
.use(Backend) // Setup our backend
36+
.init({
37+
...i18n, // spread the configuration
38+
lng, // The locale we detected above
39+
ns, // The namespaces the routes about to render wants to use
40+
backend: { loadPath: resolve("./public/locales/{{lng}}/{{ns}}.json") },
41+
resources,
42+
})
4643

47-
return new Promise((resolve, reject) => {
48-
let didError = false;
44+
return new Promise((resolve, reject) => {
45+
let didError = false
4946

50-
const { pipe, abort } = renderToPipeableStream(
51-
<I18nextProvider i18n={instance}>
52-
<RemixServer context={remixContext} url={request.url} />
53-
</I18nextProvider>,
54-
{
55-
[callbackName]: () => {
56-
const body = new PassThrough();
47+
const { pipe, abort } = renderToPipeableStream(
48+
<I18nextProvider i18n={instance}>
49+
<RemixServer context={remixContext} url={request.url} />
50+
</I18nextProvider>,
51+
{
52+
[callbackName]: () => {
53+
const body = new PassThrough()
5754

58-
responseHeaders.set("Content-Type", "text/html");
55+
responseHeaders.set("Content-Type", "text/html")
5956

60-
resolve(
61-
new Response(body, {
62-
headers: responseHeaders,
63-
status: didError ? 500 : responseStatusCode,
64-
})
65-
);
57+
resolve(
58+
new Response(body, {
59+
headers: responseHeaders,
60+
status: didError ? 500 : responseStatusCode,
61+
})
62+
)
6663

67-
pipe(body);
68-
},
69-
onShellError(error: unknown) {
70-
reject(error);
71-
},
72-
onError(error: unknown) {
73-
didError = true;
64+
pipe(body)
65+
},
66+
onShellError(error: unknown) {
67+
reject(error)
68+
},
69+
onError(error: unknown) {
70+
didError = true
7471

75-
console.error(error);
76-
},
77-
}
78-
);
72+
console.error(error)
73+
},
74+
}
75+
)
7976

80-
setTimeout(abort, ABORT_DELAY);
81-
});
77+
setTimeout(abort, ABORT_DELAY)
78+
})
8279
}

0 commit comments

Comments
 (0)