Skip to content

Commit c2d2d68

Browse files
authored
Add support for Biome (#982)
1 parent f15a462 commit c2d2d68

33 files changed

+1851
-798
lines changed

.changeset/rude-pandas-yawn.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sumup-oss/foundry": minor
3+
---
4+
5+
Added support for [Biome](https://biomejs.dev/) to replace Prettier for formatting code and to supplement ESLint for linting code. Written in Rust, Biome is orders of magnitude faster, however, it doesn't support as many rules or plugins yet.

.github/workflows/ci.yaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: actions/setup-node@v4
1717
with:
1818
node-version: ${{ matrix.node }}
19-
cache: 'npm'
19+
cache: "npm"
2020

2121
- name: Install dependencies
2222
run: npm ci
@@ -27,8 +27,11 @@ jobs:
2727
- name: Check licenses
2828
run: npm run check:licenses
2929

30+
- name: Build
31+
run: npm run build
32+
3033
- name: Lint
31-
run: npm run lint
34+
run: npm run lint:ci
3235

3336
- name: Unit test
3437
run: npm run test:ci

.huskyrc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
// run their own binaries.
1919
module.exports = {
2020
hooks: {
21-
'pre-commit': 'lint-staged'
22-
}
21+
'pre-commit': 'lint-staged',
22+
},
2323
};

.prettierignore

-2
This file was deleted.

biome.jsonc

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.8.2/schema.json",
3+
"extends": ["./src/configs/biome/biome.jsonc"],
4+
"organizeImports": { "enabled": false },
5+
"linter": {
6+
"rules": {
7+
"style": {
8+
"noDefaultExport": "error",
9+
"useFilenamingConvention": {
10+
"level": "error",
11+
"options": {
12+
"requireAscii": true,
13+
"filenameCases": ["kebab-case"]
14+
}
15+
}
16+
},
17+
"suspicious": {
18+
"noExplicitAny": "off"
19+
}
20+
}
21+
},
22+
"overrides": [
23+
{
24+
// Workaround to match the format that npm uses
25+
"include": ["package.json"],
26+
"json": {
27+
"formatter": {
28+
"lineWidth": 1
29+
}
30+
}
31+
},
32+
{
33+
"include": ["src/lib/logger.ts"],
34+
"linter": {
35+
"rules": {
36+
"suspicious": {
37+
"noConsoleLog": "off"
38+
}
39+
}
40+
}
41+
}
42+
]
43+
}

lint-staged.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
// since it tries to run a command through Foundry. Packages cannot
1818
// run their own binaries.
1919
module.exports = {
20+
'*': [
21+
'biome check --write --no-errors-on-unmatched --files-ignore-unknown=true',
22+
],
2023
'*.(js|jsx|ts|tsx)': ['eslint --fix'],
2124
'*.(ts|tsx)': () => 'tsc -p tsconfig.json --noEmit',
2225
};

package-lock.json

+158-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@
1616
"./husky": "./dist/husky.js",
1717
"./lint-staged": "./dist/lint-staged.js",
1818
"./prettier": "./dist/prettier.js",
19-
"./stylelint": "./dist/stylelint.js"
19+
"./stylelint": "./dist/stylelint.js",
20+
"./biome": "./dist/biome.jsonc"
2021
},
2122
"scripts": {
22-
"build": "npm run cleanup && tsc && chmod +x dist/cli/index.js",
23+
"build": "npm run cleanup && tsc && chmod +x dist/cli/index.js && cp src/configs/biome/biome.jsonc dist/biome.jsonc",
2324
"dev": "npm run cleanup && tsc --watch",
2425
"start": "npm run dev",
2526
"cleanup": "rimraf ./dist && mkdir dist",
26-
"prelint": "npm run build",
27-
"lint": "eslint src --ext .js,.jsx,.json,.ts,.tsx",
28-
"lint:fix": "npm run lint -- --fix",
27+
"lint": "biome check && eslint src --ext .js,.jsx,.json,.ts,.tsx",
28+
"lint:fix": "biome check --write && eslint src --ext .js,.jsx,.json,.ts,.tsx --fix",
29+
"lint:ci": "biome ci && eslint src --ext .js,.jsx,.json,.ts,.tsx",
2930
"test": "vitest",
3031
"test:ci": "vitest run --coverage",
3132
"codecov": "codecov",
3233
"check:security": "audit-ci --critical",
3334
"check:licenses": "license-checker --production --summary --failOn=GPLv3",
34-
"prerelease": "npm run build",
3535
"release": "changeset publish"
3636
},
3737
"engines": {
@@ -81,6 +81,7 @@
8181
"yargs": "^17.7.2"
8282
},
8383
"devDependencies": {
84+
"@biomejs/biome": "1.8.2",
8485
"@changesets/changelog-github": "^0.5.0",
8586
"@changesets/cli": "^2.27.1",
8687
"@types/cross-spawn": "^6.0.6",

src/cli/defaults.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
* limitations under the License.
1414
*/
1515

16-
import { InitOptions } from '../types/shared';
16+
import type { InitOptions } from '../types/shared';
1717

1818
export const DEFAULT_OPTIONS: InitOptions = {
1919
configDir: '.',
2020
openSource: false,
2121
overwrite: false,
22+
useBiome: true,
2223
};

src/cli/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
import yargs from 'yargs';
1919

20-
import { run, RunParams } from './run';
21-
import { init, InitParams } from './init';
20+
import { run, type RunParams } from './run';
21+
import { init, type InitParams } from './init';
2222
import { debug } from './debug';
2323
import { DEFAULT_OPTIONS } from './defaults';
2424

0 commit comments

Comments
 (0)