Thanks to visit codestin.com
Credit goes to github.com

Skip to content

chore: configure biome linter #616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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,11 +41,10 @@
}
}


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

execSync(`git tag v${version}`);
execSync(`git push origin --tags`);

Check warning on line 50 in .changeset/aggregate.mjs

View workflow job for this annotation

GitHub Actions / validate

lint/style/noUnusedTemplateLiteral

Do not use template literals if interpolation and special-character handling are not needed.
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you apply these safe fixes ? If so no need to set them as warn, we want to avoid them as much as possible so an error is fine

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've only applied the fixes that were causing formatting or import order errors, which I forgot to mention. Now, running pnpm lint exits with 0, while pnpm lint:fix would apply additional linting fixes. It might be better to address these in the next PR, as they are more nuanced and might not be necessary if some rules are disabled.

"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
Loading