Skip to content

Commit 04379e2

Browse files
authored
chore: configure biome linter (opennextjs#616)
* chore(lint): move to biome instead of eslint (opennextjs#538) * chore(lint): apply biome safe fixes * chore: add .git-blame-ignore-revs with bulk formatting/linting changes - Added .git-blame-ignore-revs file to exclude commit b36196d from `git blame` to improve readability by ignoring non-functional bulk edits made by Biome formatter and linter. * chore(lint): disable a11y rules in biome config * chore(vscode): add biome extension to recommended * chore(vscode): configure biome as default formatter * chore(lint): update lint script to include format and import sort checks * chore: remove .editorconfig in favor of Biome configuration
1 parent 6e53019 commit 04379e2

35 files changed

+307
-2102
lines changed

.changeset/aggregate.mjs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { execSync } from "node:child_process";
12
import fs from "node:fs/promises";
23
import path from "node:path";
3-
import { execSync } from "node:child_process";
44

55
const THANKLESS_COMMITTERS = ["thdxr", "fwang", "jayair", "conico974"];
66

@@ -11,11 +11,7 @@ const { version } = JSON.parse(
1111
const changes = new Set();
1212

1313
// We only need to look for changes in packages/open-next
14-
const changelog = path.join(
15-
"packages",
16-
"open-next",
17-
"CHANGELOG.md",
18-
);
14+
const changelog = path.join("packages", "open-next", "CHANGELOG.md");
1915
const lines = (await fs.readFile(changelog)).toString().split("\n");
2016
let start = false;
2117
for (let line of lines) {
@@ -45,7 +41,6 @@ for (let line of lines) {
4541
}
4642
}
4743

48-
4944
const notes = ["#### Changes", ...changes];
5045
console.log(notes.join("\n"));
5146
console.log(`::set-output name=notes::${notes.join("%0A")}`);

.eslintrc.cjs

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

.git-blame-ignore-revs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
b36196d4ff17934ed71b0926effa20a5a6c1433d

.github/actions/lint/action.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
name: Lint codebase
2-
description: Run eslint to lint codebase and ensure code quality
2+
description: Run biome to lint codebase and ensure code quality
33

44
runs:
5-
using: 'composite'
5+
using: "composite"
66
steps:
77
- name: Install dependencies
88
run: pnpm install
99
shell: bash
1010

11-
- name: Run eslint
12-
run: pnpm lint
11+
- name: Setup Biome CLI
12+
uses: biomejs/[email protected]
13+
14+
- name: Run biome
15+
run: biome ci --reporter=github
1316
shell: bash

.github/workflows/release.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ jobs:
1717
uses: actions/checkout@v4
1818

1919
- uses: ./.github/actions/pnpm-setup
20-
21-
- name: Install dependencies
22-
run: pnpm install
23-
24-
- name: Check codestyle
25-
run: pnpm lint
20+
- uses: ./.github/actions/lint
2621

2722
- name: Create Release Pull Request or Publish to npm
2823
id: changesets

.vscode/extensions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["biomejs.biome"]
3+
}

.vscode/settings.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,22 @@
33
"**/.turbo": true
44
},
55
"tailwindCSS.classAttributes": ["class", "className", "tw"],
6-
"prettier.trailingComma": "all"
6+
"[typescript]": {
7+
"editor.defaultFormatter": "biomejs.biome"
8+
},
9+
"[typescriptreact]": {
10+
"editor.defaultFormatter": "biomejs.biome"
11+
},
12+
"[javascript]": {
13+
"editor.defaultFormatter": "biomejs.biome"
14+
},
15+
"[javascriptreact]": {
16+
"editor.defaultFormatter": "biomejs.biome"
17+
},
18+
"[json]": {
19+
"editor.defaultFormatter": "biomejs.biome"
20+
},
21+
"[css]": {
22+
"editor.defaultFormatter": "biomejs.biome"
23+
}
724
}

biome.jsonc

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3+
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
4+
"files": {
5+
"ignoreUnknown": true
6+
},
7+
"organizeImports": { "enabled": true },
8+
"formatter": { "enabled": true, "indentStyle": "space" },
9+
"css": { "formatter": { "quoteStyle": "single" } },
10+
"linter": {
11+
"enabled": true,
12+
"rules": {
13+
"a11y": {
14+
"all": false
15+
},
16+
"suspicious": {
17+
"noExplicitAny": "info",
18+
"noGlobalIsNan": "warn",
19+
"noImplicitAnyLet": "warn",
20+
"noAssignInExpressions": "warn",
21+
"noConfusingVoidType": "warn",
22+
"useNamespaceKeyword": "warn" // safe fix
23+
},
24+
"style": {
25+
"noUnusedTemplateLiteral": "warn",
26+
"noInferrableTypes": "warn", // safe fix
27+
"noUselessElse": "warn",
28+
"useNodejsImportProtocol": "warn",
29+
"useTemplate": "warn",
30+
"useNumberNamespace": "warn", // safe fix
31+
"noNonNullAssertion": "warn",
32+
"useImportType": "warn",
33+
"noParameterAssign": "warn",
34+
"useDefaultParameterLast": "warn",
35+
"noCommaOperator": "warn",
36+
"useConst": "warn",
37+
"useSingleVarDeclarator": "warn",
38+
"noVar": "warn",
39+
"useShorthandFunctionType": "warn" // safe fix
40+
},
41+
"correctness": {
42+
"noSwitchDeclarations": "warn",
43+
"noUnnecessaryContinue": "warn",
44+
"noInnerDeclarations": "warn"
45+
},
46+
"complexity": {
47+
"useLiteralKeys": "warn",
48+
"noForEach": "off",
49+
"noUselessSwitchCase": "warn",
50+
"noUselessConstructor": "warn",
51+
"noBannedTypes": "warn",
52+
"noUselessTernary": "warn",
53+
"useArrowFunction": "warn", // safe fix
54+
"noExtraBooleanCast": "warn",
55+
"useOptionalChain": "warn"
56+
},
57+
"performance": {
58+
"noDelete": "warn",
59+
"noAccumulatingSpread": "warn"
60+
}
61+
}
62+
},
63+
"overrides": [
64+
{
65+
"include": ["packages/tests-unit/**", "packages/tests-e2e/**"],
66+
"linter": {
67+
"rules": {
68+
"suspicious": {
69+
"noRedeclare": "warn"
70+
}
71+
}
72+
}
73+
},
74+
{
75+
"include": ["examples/**/*"],
76+
"linter": {
77+
"rules": {
78+
"style": {
79+
"useSelfClosingElements": "warn"
80+
},
81+
"correctness": {
82+
"useJsxKeyInIterable": "warn",
83+
"useExhaustiveDependencies": "warn"
84+
},
85+
"suspicious": {
86+
"noArrayIndexKey": "warn",
87+
"noRedeclare": "warn"
88+
}
89+
}
90+
}
91+
}
92+
]
93+
}

examples/app-pages-router/styles/globals.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
:root {
66
--max-width: 1100px;
77
--border-radius: 12px;
8-
--font-mono: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono',
8+
--font-mono:
9+
ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono',
910
'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro',
1011
'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;
1112

examples/app-router/app/api/isr/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import path from "path";
12
import fs from "fs/promises";
23
import type { NextRequest } from "next/server";
34
import { NextResponse } from "next/server";
4-
import path from "path";
55

66
export const dynamic = "force-dynamic";
77

0 commit comments

Comments
 (0)