Skip to content

Commit

Permalink
chore: configure biome linter (#616)
Browse files Browse the repository at this point in the history
* chore(lint): move to biome instead of eslint (#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
  • Loading branch information
maxmorozoff authored Nov 8, 2024
1 parent 6e53019 commit 04379e2
Show file tree
Hide file tree
Showing 35 changed files with 307 additions and 2,102 deletions.
9 changes: 2 additions & 7 deletions .changeset/aggregate.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { execSync } from "node:child_process";
import fs from "node:fs/promises";
import path from "node:path";
import { execSync } from "node:child_process";

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

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

// We only need to look for changes in packages/open-next
const changelog = path.join(
"packages",
"open-next",
"CHANGELOG.md",
);
const changelog = path.join("packages", "open-next", "CHANGELOG.md");
const lines = (await fs.readFile(changelog)).toString().split("\n");
let start = false;
for (let line of lines) {
Expand Down Expand Up @@ -45,7 +41,6 @@ for (let line of lines) {
}
}


const notes = ["#### Changes", ...changes];
console.log(notes.join("\n"));
console.log(`::set-output name=notes::${notes.join("%0A")}`);
Expand Down
46 changes: 0 additions & 46 deletions .eslintrc.cjs

This file was deleted.

1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b36196d4ff17934ed71b0926effa20a5a6c1433d
11 changes: 7 additions & 4 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
name: Lint codebase
description: Run eslint to lint codebase and ensure code quality
description: Run biome to lint codebase and ensure code quality

runs:
using: 'composite'
using: "composite"
steps:
- name: Install dependencies
run: pnpm install
shell: bash

- name: Run eslint
run: pnpm lint
- name: Setup Biome CLI
uses: biomejs/[email protected]

- name: Run biome
run: biome ci --reporter=github
shell: bash
7 changes: 1 addition & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ jobs:
uses: actions/checkout@v4

- uses: ./.github/actions/pnpm-setup

- name: Install dependencies
run: pnpm install

- name: Check codestyle
run: pnpm lint
- uses: ./.github/actions/lint

- name: Create Release Pull Request or Publish to npm
id: changesets
Expand Down
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["biomejs.biome"]
}
19 changes: 18 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,22 @@
"**/.turbo": true
},
"tailwindCSS.classAttributes": ["class", "className", "tw"],
"prettier.trailingComma": "all"
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[javascriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[css]": {
"editor.defaultFormatter": "biomejs.biome"
}
}
93 changes: 93 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
"files": {
"ignoreUnknown": true
},
"organizeImports": { "enabled": true },
"formatter": { "enabled": true, "indentStyle": "space" },
"css": { "formatter": { "quoteStyle": "single" } },
"linter": {
"enabled": true,
"rules": {
"a11y": {
"all": false
},
"suspicious": {
"noExplicitAny": "info",
"noGlobalIsNan": "warn",
"noImplicitAnyLet": "warn",
"noAssignInExpressions": "warn",
"noConfusingVoidType": "warn",
"useNamespaceKeyword": "warn" // safe fix
},
"style": {
"noUnusedTemplateLiteral": "warn",
"noInferrableTypes": "warn", // safe fix
"noUselessElse": "warn",
"useNodejsImportProtocol": "warn",
"useTemplate": "warn",
"useNumberNamespace": "warn", // safe fix
"noNonNullAssertion": "warn",
"useImportType": "warn",
"noParameterAssign": "warn",
"useDefaultParameterLast": "warn",
"noCommaOperator": "warn",
"useConst": "warn",
"useSingleVarDeclarator": "warn",
"noVar": "warn",
"useShorthandFunctionType": "warn" // safe fix
},
"correctness": {
"noSwitchDeclarations": "warn",
"noUnnecessaryContinue": "warn",
"noInnerDeclarations": "warn"
},
"complexity": {
"useLiteralKeys": "warn",
"noForEach": "off",
"noUselessSwitchCase": "warn",
"noUselessConstructor": "warn",
"noBannedTypes": "warn",
"noUselessTernary": "warn",
"useArrowFunction": "warn", // safe fix
"noExtraBooleanCast": "warn",
"useOptionalChain": "warn"
},
"performance": {
"noDelete": "warn",
"noAccumulatingSpread": "warn"
}
}
},
"overrides": [
{
"include": ["packages/tests-unit/**", "packages/tests-e2e/**"],
"linter": {
"rules": {
"suspicious": {
"noRedeclare": "warn"
}
}
}
},
{
"include": ["examples/**/*"],
"linter": {
"rules": {
"style": {
"useSelfClosingElements": "warn"
},
"correctness": {
"useJsxKeyInIterable": "warn",
"useExhaustiveDependencies": "warn"
},
"suspicious": {
"noArrayIndexKey": "warn",
"noRedeclare": "warn"
}
}
}
}
]
}
3 changes: 2 additions & 1 deletion examples/app-pages-router/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
:root {
--max-width: 1100px;
--border-radius: 12px;
--font-mono: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono',
--font-mono:
ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono',
'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro',
'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;

Expand Down
2 changes: 1 addition & 1 deletion examples/app-router/app/api/isr/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from "path";
import fs from "fs/promises";
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
import path from "path";

export const dynamic = "force-dynamic";

Expand Down
3 changes: 2 additions & 1 deletion examples/pages-router/src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
:root {
--max-width: 1100px;
--border-radius: 12px;
--font-mono: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono',
--font-mono:
ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono',
'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro',
'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;

Expand Down
66 changes: 33 additions & 33 deletions examples/shared/api/songs.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
{
"songs": [
{
"rank": 1,
"title": "I'm never gonna give you up",
"artist": "Rick Astley",
"album": "Hold Me In Your Arms",
"year": "1965",
"videoId": "dQw4w9WgXcQ"
},
{
"rank": 2,
"title": "My Wang",
"artist": "Frank Wangnatra",
"album": "@franjiewang",
"year": "2023",
"videoId": "qQzdAsjWGPg"
},
{
"rank": 3,
"title": "Excuse me miSST",
"artist": "Jay-Air",
"album": "@Jayair",
"year": "2023",
"videoId": "tnDh0JhmaFw"
},
{
"rank": 4,
"title": "I don't want another CONSOLE-RRY",
"artist": "Dax",
"album": "@thxdr",
"year": "2023",
"videoId": "4JI70_9acgE"
}
{
"rank": 1,
"title": "I'm never gonna give you up",
"artist": "Rick Astley",
"album": "Hold Me In Your Arms",
"year": "1965",
"videoId": "dQw4w9WgXcQ"
},
{
"rank": 2,
"title": "My Wang",
"artist": "Frank Wangnatra",
"album": "@franjiewang",
"year": "2023",
"videoId": "qQzdAsjWGPg"
},
{
"rank": 3,
"title": "Excuse me miSST",
"artist": "Jay-Air",
"album": "@Jayair",
"year": "2023",
"videoId": "tnDh0JhmaFw"
},
{
"rank": 4,
"title": "I don't want another CONSOLE-RRY",
"artist": "Dax",
"album": "@thxdr",
"year": "2023",
"videoId": "4JI70_9acgE"
}
]
}
}
2 changes: 1 addition & 1 deletion examples/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"@types/react": "npm:[email protected]",
"@types/react-dom": "npm:[email protected]"
}
}
}
12 changes: 3 additions & 9 deletions examples/shared/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{
"include": [
"."
],
"exclude": [
"dist",
"build",
"node_modules"
],
"include": ["."],
"exclude": ["dist", "build", "node_modules"],
"compilerOptions": {
"composite": false,
"declaration": false,
Expand Down Expand Up @@ -35,4 +29,4 @@
"~/*": ["./*"]
}
}
}
}
Loading

0 comments on commit 04379e2

Please sign in to comment.