Skip to content

Commit

Permalink
Merge pull request #59 from jmuzina/package-script-cleanup
Browse files Browse the repository at this point in the history
Biome formatting/linting fixes
  • Loading branch information
advl authored Dec 9, 2024
2 parents ee6a5ef + 167301d commit 39ef575
Show file tree
Hide file tree
Showing 27 changed files with 55 additions and 75 deletions.
4 changes: 3 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Fixes [list issues/bugs if needed]

- [ ] PR should have one of the following labels:
- `Feature 🎁`, `Breaking Change 💣`, `Bug 🐛`, `Documentation 📝`, `Maintenance 🔨`.
- [ ] All packages define the required scripts in `package.json`: `build`, `check`, and `check:fix`.
- [ ] All packages define the required scripts in `package.json`:
- [ ] All packages: `check` and `check:fix`.
- [ ] Packages with a build step: `build`.

## Screenshots

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env

- name: Run tests
run: bun run test
- name: Code quality checks
run: bun run check
4 changes: 2 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env

- name: Run tests
run: bun run test
- name: Code quality checks
run: bun run check
4 changes: 2 additions & 2 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ jobs:
uses: ./.github/actions/setup-env

# TODO add Nx and only test the packages that have changed since last tag
- name: Run tests
run: bun run test
- name: Code quality checks
run: bun run check

version:
name: Bump package versions
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ in the monorepo.
Each package should define the following scripts in `package.json`:

- `build`: Builds the package as preparation for publishing or use by its dependencies.
- `check`: Lints and type-checks the package.
- `check:fix`: Lints and type-checks the package, and applies fixes where possible.
- `check`: Lints, formats, and (if applicable) type-checks the package.
- `check:fix`: Lints, formats, type-checks, and fixes issues where possible.

By creating these scripts in each package, the build and check tasks will be
included in the monorepo's CI workflow, helping to avoid build errors later.
Expand Down
2 changes: 1 addition & 1 deletion apps/boilerplate-react-vite/biome.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"extends": ["@canonical/biome-config"]
}
11 changes: 4 additions & 7 deletions apps/boilerplate-react-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"lint": "biome lint src/**/*.{ts,tsx}",
"format": "bun run format:biome",
"format:biome": "biome format src/**/*.{ts,tsx}",
"check": "bun run check:biome && bun run check:ts",
"check:fix": "bun run check:biome:fix",
"check:biome": "biome check src/**/* *.json",
"check:biome:fix": "biome check --write src/**/* *.json",
"check:fix": "bun run check:biome:fix && bun run check:ts",
"check:biome": "biome check src *.json",
"check:biome:fix": "biome check --write src *.json",
"check:ts": "tsc --noEmit"
},
"dependencies": {
Expand All @@ -23,7 +20,7 @@
"react-dom": "^19.0.0-rc-1460d67c-20241003"
},
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@biomejs/biome": "^1.9.4",
"@canonical/biome-config": "^0.3.1-experimental.0",
"@canonical/ds-react-core": "^0.3.1-experimental.0",
"@canonical/typescript-config-react": "^0.3.1-experimental.0",
Expand Down
9 changes: 5 additions & 4 deletions apps/boilerplate-react-vite/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from "react";
import reactLogo from "./assets/react.svg";
import canonicalLogo from "/canonical.svg";
import reactLogo from "./assets/react.svg";
import "./App.css";

import { Button } from "@canonical/ds-react-core";
Expand All @@ -15,10 +15,11 @@ function App() {
href="https://canonical.com"
target="_blank"
referrerPolicy="no-referrer"
rel="noreferrer"
>
<img src={canonicalLogo} className="logo" alt="Canonical logo"></img>
<img src={canonicalLogo} className="logo" alt="Canonical logo" />
</a>
<a href="https://react.dev" target="_blank">
<a href="https://react.dev" target="_blank" rel="noreferrer">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
Expand All @@ -28,7 +29,7 @@ function App() {
<Button
label={`Count: ${count}`}
onClick={() => setCount((count) => count + 1)}
></Button>
/>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
Expand Down
12 changes: 6 additions & 6 deletions apps/boilerplate-react-vite/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App.js'
import './index.css'
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App.js";
import "./index.css";

createRoot(document.getElementById('root') as HTMLElement).render(
createRoot(document.getElementById("root") as HTMLElement).render(
<StrictMode>
<App />
</StrictMode>,
)
);
2 changes: 1 addition & 1 deletion apps/generator-canonical-ds/biome.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"extends": ["@canonical/biome-config"]
}
8 changes: 3 additions & 5 deletions apps/generator-canonical-ds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
"build": "bun run build:tsc && bun run build:copyfiles",
"build:tsc": "tsc",
"build:copyfiles": "copyfiles -u 1 src/**/templates/**/* generators",
"lint:biome": "biome lint src/*.ts",
"format:biome": "biome format src/*.ts",
"check": "bun run check:biome && bun run check:ts",
"check:fix": "bun run check:biome:fix",
"check:biome": "biome check src/**/*.ts *.json",
"check:biome:fix": "biome check --write src/**/*.ts *.json",
"check:fix": "bun run check:biome:fix && bun run check:ts",
"check:biome": "biome check src *.json",
"check:biome:fix": "biome check --write src *.json",
"check:ts": "tsc --noEmit"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion apps/ts_example/biome.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"extends": ["@canonical/biome-config"]
}
11 changes: 4 additions & 7 deletions apps/ts_example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,17 @@
"homepage": "https://github.com/canonical/ds25#readme",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"test": "echo \"Error: no test specified\" && exit 1",
"lint:biome": "biome lint src/*.ts",
"format:biome": "biome format src/*.ts",
"check": "bun run check:biome && bun run check:ts",
"check:fix": "bun run check:biome:fix",
"check:biome": "biome check src/*.ts *.json",
"check:biome:fix": "biome check --write src/*.ts *.json",
"check:fix": "bun run check:biome:fix && bun run check:ts",
"check:biome": "biome check src *.json",
"check:biome:fix": "biome check --write src *.json",
"check:ts": "tsc --noEmit"
},
"dependencies": {
"@canonical/utils": "^0.3.1-experimental.0"
},
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@biomejs/biome": "^1.9.4",
"@canonical/biome-config": "^0.3.1-experimental.0",
"@canonical/typescript-config-base": "^0.3.1-experimental.0"
}
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion configs/biome/biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
Expand Down
4 changes: 2 additions & 2 deletions configs/biome/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"check:biome:fix": "biome check --write *.json"
},
"devDependencies": {
"@biomejs/biome": "^1.9.2"
"@biomejs/biome": "^1.9.4"
},
"peerDependencies": {
"@biomejs/biome": "^1.9.2"
"@biomejs/biome": "^1.9.4"
}
}
1 change: 0 additions & 1 deletion configs/typescript-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
},
"homepage": "https://github.com/canonical/ds25#readme",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"check": "bun run check:biome",
"check:fix": "bun run check:biome:fix",
"check:biome": "biome check *.json",
Expand Down
1 change: 0 additions & 1 deletion configs/typescript-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
},
"homepage": "https://github.com/canonical/ds25#readme",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"check": "bun run check:biome",
"check:fix": "bun run check:biome:fix",
"check:biome": "biome check *.json",
Expand Down
1 change: 0 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"cli": {
"packageManager": "bun"
},
"cacheableOperations": ["build", "test", "check", "check:fix"],
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"build": "lerna run build",
"prepare": "bun run build",
"lerna": "lerna",
"test": "bun run check",
"check": "lerna run check",
"check:fix": "lerna run check:fix"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/ds-react-core/biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"extends": ["@canonical/biome-config"],
"files": {
"ignore": ["src/styles/normalize.css"]
Expand Down
15 changes: 5 additions & 10 deletions packages/ds-react-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,14 @@
"homepage": "https://github.com/canonical/ds25#readme",
"scripts": {
"build": "bun run build:package",
"build:storybook": "bun run build-storybook",
"build-storybook": "storybook build",
"build:storybook": "storybook build",
"build:package": "bun run build:package:tsc && bun run build:package:copycss",
"build:package:bun": "bun build --root src src/**/**/*.{ts,tsx} --outdir dist/esm --sourcemap=linked --external '*' && tsc -p tsconfig.build.json --emitDeclarationOnly",
"build:package:copycss": "copyfiles -u 1 src/ui/**/*.css dist/esm",
"build:package:tsc": "tsc -p tsconfig.build.json",
"lint": "biome lint src/**/*.{ts,tsx}",
"format": "bun run format:biome",
"format:biome": "biome format src/**/*.{ts,tsx}",
"check": "bun run check:biome && bun run check:ts",
"check:fix": "bun run check:biome:fix",
"check:biome": "biome check src/**/* *.json",
"check:biome:old": "biome check src/**/*.{ts,tsx,mdx} *.json",
"check:biome:fix": "biome check --write src/**/* *.json",
"check:fix": "bun run check:biome:fix && bun run check:ts",
"check:biome": "biome check src *.json",
"check:biome:fix": "biome check --write src *.json",
"check:ts": "tsc --noEmit",
"storybook": "storybook dev -p 6006 --no-open --host 0.0.0.0"
},
Expand All @@ -43,6 +37,7 @@
"react-dom": "^19.0.0-rc-1460d67c-20241003"
},
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@canonical/biome-config": "^0.3.1-experimental.0",
"@canonical/typescript-config-react": "^0.3.1-experimental.0",
"@chromatic-com/storybook": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/ds-react-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './ui/index.js';
export * from "./ui/index.js";
2 changes: 1 addition & 1 deletion packages/styles/biome.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"extends": ["@canonical/biome-config"]
}
9 changes: 3 additions & 6 deletions packages/styles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@
},
"homepage": "https://github.com/canonical/ds25#readme",
"scripts": {
"lint": "biome lint src/*.{css}",
"format": "bun run format:biome",
"format:biome": "biome format src/*.{css}",
"check": "bun run check:biome",
"check:fix": "bun run check:biome:fix",
"check:biome": "biome check src/* *.json",
"check:biome:fix": "biome check --write src/* *.json"
"check:biome": "biome check src *.json",
"check:biome:fix": "biome check --write src *.json"
},
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@biomejs/biome": "^1.9.4",
"@canonical/biome-config": "^0.3.1-experimental.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/biome.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"extends": ["@canonical/biome-config"]
}
11 changes: 4 additions & 7 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@
"homepage": "https://github.com/canonical/ds25#readme",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"lint": "biome lint src/*.{ts,tsx}",
"format": "bun run format:biome",
"format:biome": "biome format src/*.{ts,tsx}",
"check": "bun run check:biome && bun run check:ts",
"check:fix": "bun run check:biome:fix",
"check:biome": "biome check src/* *.json",
"check:biome:fix": "biome check --write src/* *.json",
"check:fix": "bun run check:biome:fix && bun run check:ts",
"check:biome": "biome check src *.json",
"check:biome:fix": "biome check --write src *.json",
"check:ts": "tsc --noEmit"
},
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@biomejs/biome": "^1.9.4",
"@canonical/biome-config": "^0.1.0-experimental.0",
"@canonical/typescript-config-base": "^0.3.1-experimental.0",
"typescript": "^5.5.3"
Expand Down

0 comments on commit 39ef575

Please sign in to comment.