Skip to content

Commit

Permalink
Add support for Biome (#982)
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer authored Jun 22, 2024
1 parent f15a462 commit c2d2d68
Show file tree
Hide file tree
Showing 33 changed files with 1,851 additions and 798 deletions.
5 changes: 5 additions & 0 deletions .changeset/rude-pandas-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sumup-oss/foundry": minor
---

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.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'npm'
cache: "npm"

- name: Install dependencies
run: npm ci
Expand All @@ -27,8 +27,11 @@ jobs:
- name: Check licenses
run: npm run check:licenses

- name: Build
run: npm run build

- name: Lint
run: npm run lint
run: npm run lint:ci

- name: Unit test
run: npm run test:ci
Expand Down
4 changes: 2 additions & 2 deletions .huskyrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
// run their own binaries.
module.exports = {
hooks: {
'pre-commit': 'lint-staged'
}
'pre-commit': 'lint-staged',
},
};
2 changes: 0 additions & 2 deletions .prettierignore

This file was deleted.

43 changes: 43 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.2/schema.json",
"extends": ["./src/configs/biome/biome.jsonc"],
"organizeImports": { "enabled": false },
"linter": {
"rules": {
"style": {
"noDefaultExport": "error",
"useFilenamingConvention": {
"level": "error",
"options": {
"requireAscii": true,
"filenameCases": ["kebab-case"]
}
}
},
"suspicious": {
"noExplicitAny": "off"
}
}
},
"overrides": [
{
// Workaround to match the format that npm uses
"include": ["package.json"],
"json": {
"formatter": {
"lineWidth": 1
}
}
},
{
"include": ["src/lib/logger.ts"],
"linter": {
"rules": {
"suspicious": {
"noConsoleLog": "off"
}
}
}
}
]
}
3 changes: 3 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
// since it tries to run a command through Foundry. Packages cannot
// run their own binaries.
module.exports = {
'*': [
'biome check --write --no-errors-on-unmatched --files-ignore-unknown=true',
],
'*.(js|jsx|ts|tsx)': ['eslint --fix'],
'*.(ts|tsx)': () => 'tsc -p tsconfig.json --noEmit',
};
160 changes: 158 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
"./husky": "./dist/husky.js",
"./lint-staged": "./dist/lint-staged.js",
"./prettier": "./dist/prettier.js",
"./stylelint": "./dist/stylelint.js"
"./stylelint": "./dist/stylelint.js",
"./biome": "./dist/biome.jsonc"
},
"scripts": {
"build": "npm run cleanup && tsc && chmod +x dist/cli/index.js",
"build": "npm run cleanup && tsc && chmod +x dist/cli/index.js && cp src/configs/biome/biome.jsonc dist/biome.jsonc",
"dev": "npm run cleanup && tsc --watch",
"start": "npm run dev",
"cleanup": "rimraf ./dist && mkdir dist",
"prelint": "npm run build",
"lint": "eslint src --ext .js,.jsx,.json,.ts,.tsx",
"lint:fix": "npm run lint -- --fix",
"lint": "biome check && eslint src --ext .js,.jsx,.json,.ts,.tsx",
"lint:fix": "biome check --write && eslint src --ext .js,.jsx,.json,.ts,.tsx --fix",
"lint:ci": "biome ci && eslint src --ext .js,.jsx,.json,.ts,.tsx",
"test": "vitest",
"test:ci": "vitest run --coverage",
"codecov": "codecov",
"check:security": "audit-ci --critical",
"check:licenses": "license-checker --production --summary --failOn=GPLv3",
"prerelease": "npm run build",
"release": "changeset publish"
},
"engines": {
Expand Down Expand Up @@ -81,6 +81,7 @@
"yargs": "^17.7.2"
},
"devDependencies": {
"@biomejs/biome": "1.8.2",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@types/cross-spawn": "^6.0.6",
Expand Down
3 changes: 2 additions & 1 deletion src/cli/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
* limitations under the License.
*/

import { InitOptions } from '../types/shared';
import type { InitOptions } from '../types/shared';

export const DEFAULT_OPTIONS: InitOptions = {
configDir: '.',
openSource: false,
overwrite: false,
useBiome: true,
};
4 changes: 2 additions & 2 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import yargs from 'yargs';

import { run, RunParams } from './run';
import { init, InitParams } from './init';
import { run, type RunParams } from './run';
import { init, type InitParams } from './init';
import { debug } from './debug';
import { DEFAULT_OPTIONS } from './defaults';

Expand Down
Loading

0 comments on commit c2d2d68

Please sign in to comment.