Skip to content

Commit 6907dba

Browse files
authored
Enable expanded Biome lint rules (#86)
* enabled Biome and format * biome recommended settings * enable cognitive complexity lint rule * enable no foreach lint rule * enable no implicit coercions lint rule * enable no conditional expect lint rule * enable no floating promises lint rule * enable no for in lint rule * enable no loop func lint rule * enable disposable lint rule * enable no await in loops lint rule * enable no barrel file lint rule * enable top level regex lint rule * enable collapsed else if lint rule * enable collapsed if lint rule * enable no nested ternary lint rule * enable no parameter assign lint rule * enable no var lint rule * enable guarded for in lint rule * enable static response methods lint rule * remove empty biome rule comments * fix mask value regex backtracking * fix constructable test mocks * Add PR quality workflow * Set Node 22.12.0 as minimum version * address biome review feedback * trigger ci * fix ci typecheck
1 parent 683504d commit 6907dba

139 files changed

Lines changed: 12588 additions & 5330 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# GitHub Workflows
2+
3+
- Pin all GitHub Actions to their commit SHA, not a tag. Append the tag as a comment for readability (e.g., `uses: actions/checkout@abc123... # v4.3.2`).

.github/workflows/pr-quality.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: PR Quality
2+
3+
# This workflow owns required PR status checks. Add only jobs that should block
4+
# merging when they fail.
5+
6+
on:
7+
pull_request:
8+
9+
concurrency:
10+
group: pr-quality-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
typecheck:
18+
name: Type Check
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
24+
with:
25+
persist-credentials: false
26+
27+
- name: Set up pnpm
28+
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
29+
30+
- name: Set up Node.js
31+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
32+
with:
33+
node-version-file: .node-version
34+
cache: pnpm
35+
36+
- name: Install dependencies
37+
run: pnpm install --frozen-lockfile
38+
39+
- name: Type check
40+
run: pnpm --recursive exec tsc --noEmit
41+
42+
lint:
43+
name: Lint
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
49+
with:
50+
persist-credentials: false
51+
52+
- name: Set up Biome
53+
uses: biomejs/setup-biome@4c91541eaada48f67d7dbd7833600ce162b68f51 # v2.7.1
54+
55+
- name: Lint
56+
run: biome ci .
57+
58+
test:
59+
name: Test
60+
runs-on: ubuntu-latest
61+
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
65+
with:
66+
persist-credentials: false
67+
68+
- name: Set up pnpm
69+
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
70+
71+
- name: Set up Node.js
72+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
73+
with:
74+
node-version-file: .node-version
75+
cache: pnpm
76+
77+
- name: Install dependencies
78+
run: pnpm install --frozen-lockfile
79+
80+
- name: Test
81+
run: pnpm --recursive test

.node-version

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

biome.jsonc

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.4.16/schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
8+
"files": {
9+
"ignoreUnknown": false
10+
},
11+
"formatter": {
12+
"enabled": true,
13+
"indentStyle": "space",
14+
"indentWidth": 2
15+
},
16+
"linter": {
17+
"enabled": true,
18+
"rules": {
19+
"recommended": true,
20+
"complexity": {
21+
"noExcessiveCognitiveComplexity": "on",
22+
"noForEach": "on",
23+
"noImplicitCoercions": "on"
24+
},
25+
"nursery": {
26+
"noConditionalExpect": "on",
27+
"noFloatingPromises": "on",
28+
"noForIn": "on",
29+
"noLoopFunc": "on",
30+
"useDisposables": "on"
31+
},
32+
"performance": {
33+
"noAwaitInLoops": "on",
34+
"noBarrelFile": "on",
35+
"useTopLevelRegex": "on"
36+
},
37+
"style": {
38+
"useCollapsedElseIf": "on",
39+
"useCollapsedIf": "on",
40+
"noNestedTernary": "on",
41+
"noParameterAssign": "on"
42+
},
43+
"suspicious": {
44+
"noVar": "on",
45+
"useGuardForIn": "on",
46+
"useStaticResponseMethods": "on"
47+
}
48+
}
49+
},
50+
"javascript": {
51+
"formatter": {
52+
"quoteStyle": "double"
53+
}
54+
},
55+
"assist": {
56+
"enabled": true,
57+
"actions": {
58+
"source": {
59+
"organizeImports": "on"
60+
}
61+
}
62+
}
63+
}

examples/next-smoke/app/globals.css

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,27 @@ body {
2121

2222
body {
2323
background:
24-
radial-gradient(circle at top left, rgba(42, 125, 99, 0.18), transparent 28rem),
25-
radial-gradient(circle at bottom right, rgba(197, 123, 74, 0.16), transparent 30rem),
24+
radial-gradient(
25+
circle at top left,
26+
rgba(42, 125, 99, 0.18),
27+
transparent 28rem
28+
),
29+
radial-gradient(
30+
circle at bottom right,
31+
rgba(197, 123, 74, 0.16),
32+
transparent 30rem
33+
),
2634
var(--bg);
2735
color: var(--text);
2836
font-family:
29-
"Iowan Old Style",
30-
"Palatino Linotype",
31-
"Book Antiqua",
32-
Palatino,
33-
Georgia,
37+
"Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia,
3438
serif;
3539
}
3640

3741
code {
3842
font-family:
39-
"SFMono-Regular",
40-
ui-monospace,
41-
"Cascadia Mono",
42-
"Segoe UI Mono",
43-
Menlo,
44-
Consolas,
45-
monospace;
43+
SFMono-Regular, ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo,
44+
Consolas, monospace;
4645
background: rgba(42, 44, 39, 0.06);
4746
border-radius: 0.5rem;
4847
padding: 0.12rem 0.4rem;

examples/next-smoke/app/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ export default function Home() {
55
<p className="eyebrow">Prisma CLI</p>
66
<h1>Next.js smoke app</h1>
77
<p className="lede">
8-
This app exists to manually test the local source Prisma CLI from inside this repository.
8+
This app exists to manually test the local source Prisma CLI from
9+
inside this repository.
910
</p>
1011
<ol className="steps">
1112
<li>

examples/next-smoke/tsconfig.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "ES2017",
4-
"lib": [
5-
"dom",
6-
"dom.iterable",
7-
"esnext"
8-
],
4+
"lib": ["dom", "dom.iterable", "esnext"],
95
"allowJs": true,
106
"skipLibCheck": true,
117
"strict": true,
@@ -30,7 +26,5 @@
3026
".next/types/**/*.ts",
3127
".next/dev/types/**/*.ts"
3228
],
33-
"exclude": [
34-
"node_modules"
35-
]
29+
"exclude": ["node_modules"]
3630
}

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
{
22
"name": "prisma-cli",
33
"private": true,
4+
"engines": {
5+
"node": ">=22.12.0"
6+
},
47
"packageManager": "pnpm@10.30.0",
58
"scripts": {
69
"build:cli": "pnpm --filter @prisma/cli build",
710
"build:compute": "pnpm --filter @prisma/compute build",
11+
"format": "biome format . --write",
12+
"lint": "biome check .",
13+
"lint:fix": "biome check . --write",
814
"lint:skills": "node scripts/validate-skills.mjs",
915
"prepare": "skills add ./skills --skill '*' --agent universal claude-code -y",
1016
"prepare:cli-publish": "node scripts/prepare-cli-publish.mjs",
@@ -15,6 +21,7 @@
1521
"prisma": "tsx packages/cli/src/bin.ts"
1622
},
1723
"devDependencies": {
24+
"@biomejs/biome": "2.4.16",
1825
"gray-matter": "^4.0.3",
1926
"pkg-pr-new": "^0.0.75",
2027
"skills": "^1.5.9",

packages/cli/src/adapters/git.ts

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// biome-ignore-all lint/performance/useTopLevelRegex: Existing git URL parsing regexes are kept inline for readability.
12
import { execFile } from "node:child_process";
23
import { promisify } from "node:util";
34

@@ -11,13 +12,20 @@ export interface GitHubRepositoryReference {
1112
url: string;
1213
}
1314

14-
export async function readGitOriginRemote(cwd: string, signal?: AbortSignal): Promise<string | null> {
15+
export async function readGitOriginRemote(
16+
cwd: string,
17+
signal?: AbortSignal,
18+
): Promise<string | null> {
1519
try {
16-
const { stdout } = await execFileAsync("git", ["config", "--get", "remote.origin.url"], {
17-
cwd,
18-
timeout: 5_000,
19-
signal,
20-
});
20+
const { stdout } = await execFileAsync(
21+
"git",
22+
["config", "--get", "remote.origin.url"],
23+
{
24+
cwd,
25+
timeout: 5_000,
26+
signal,
27+
},
28+
);
2129
const remote = stdout.trim();
2230
return remote.length > 0 ? remote : null;
2331
} catch (error) {
@@ -30,9 +38,13 @@ function isAbortError(error: unknown): boolean {
3038
return error instanceof Error && error.name === "AbortError";
3139
}
3240

33-
export function parseGitHubRepositoryUrl(value: string): GitHubRepositoryReference | null {
41+
export function parseGitHubRepositoryUrl(
42+
value: string,
43+
): GitHubRepositoryReference | null {
3444
const input = value.trim();
35-
const shorthand = input.match(/^git@github\.com:([^/\s]+)\/([^/\s]+?)(?:\.git)?$/);
45+
const shorthand = input.match(
46+
/^git@github\.com:([^/\s]+)\/([^/\s]+?)(?:\.git)?$/,
47+
);
3648

3749
if (shorthand) {
3850
return toGitHubRepositoryReference(shorthand[1], shorthand[2]);
@@ -49,7 +61,11 @@ export function parseGitHubRepositoryUrl(value: string): GitHubRepositoryReferen
4961
return null;
5062
}
5163

52-
if (parsed.protocol !== "https:" && parsed.protocol !== "http:" && parsed.protocol !== "ssh:") {
64+
if (
65+
parsed.protocol !== "https:" &&
66+
parsed.protocol !== "http:" &&
67+
parsed.protocol !== "ssh:"
68+
) {
5369
return null;
5470
}
5571

@@ -64,7 +80,10 @@ export function parseGitHubRepositoryUrl(value: string): GitHubRepositoryReferen
6480
return toGitHubRepositoryReference(owner, name);
6581
}
6682

67-
function toGitHubRepositoryReference(owner: string | undefined, name: string | undefined): GitHubRepositoryReference | null {
83+
function toGitHubRepositoryReference(
84+
owner: string | undefined,
85+
name: string | undefined,
86+
): GitHubRepositoryReference | null {
6887
if (!owner || !name || owner.includes("/") || name.includes("/")) {
6988
return null;
7089
}

0 commit comments

Comments
 (0)