Skip to content

Commit

Permalink
fix(configuration): update templates and improve Biome configuration
Browse files Browse the repository at this point in the history
release-npm
  • Loading branch information
tobua committed Jul 12, 2024
1 parent dcff587 commit c7082e5
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 81 deletions.
80 changes: 49 additions & 31 deletions configuration/biome.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,57 @@
const base = (rules: object) => ({
$schema: 'node_modules/@biomejs/biome/configuration_schema.json',
organizeImports: {
enabled: true,
},
linter: {
enabled: true,
rules: {
all: true,
...rules,
},
},
javascript: {
formatter: {
semicolons: 'asNeeded',
quoteStyle: 'single',
indentStyle: 'space',
import { merge } from 'ts-deepmerge'

const base = (configuration: object) =>
merge(
{
$schema: 'node_modules/@biomejs/biome/configuration_schema.json',
organizeImports: {
enabled: true,
},
linter: {
enabled: true,
rules: {
all: true,
},
},
javascript: {
formatter: {
semicolons: 'asNeeded',
quoteStyle: 'single',
indentStyle: 'space',
},
},
files: {
// Bundled dist files will make Biome hang forever.
ignore: ['node_modules', 'dist', 'package.json'],
},
formatter: {
lineWidth: 140,
formatWithErrors: true,
},
},
},
files: {
// Bundled dist files will make Biome hang forever.
ignore: ['node_modules', 'dist', 'package.json'],
},
formatter: {
lineWidth: 140,
formatWithErrors: true,
},
})
configuration,
)

export const templates = {
recommended: base({}),
ninja: base({
style: {
useNamingConvention: 'off',
useBlockStatements: 'off',
noImplicitBoolean: 'off',
linter: {
rules: {
style: {
useNamingConvention: 'off',
useBlockStatements: 'off',
noImplicitBoolean: 'off',
},
correctness: {
noNodejsModules: 'off',
},
complexity: {
noForEach: 'off',
},
},
},
options: {
maxAllowedComplexity: 10, // Default is 15.
},
}),
}
Expand Down
10 changes: 5 additions & 5 deletions template/default/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"scripts": {
"build": "bun build index.tsx --outdir public",
"check": "biome check --apply .",
"check": "biome check --write .",
"server": "bun --watch server.ts",
"start": "bun watch & bun server",
"types": "tsc",
"watch": "bun build index.tsx --outdir public --watch"
},
"dependencies": {
"@biomejs/biome": "^1.8.1",
"@biomejs/biome": "^1.8.3",
"@elysiajs/static": "^1.0.3",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"elysia": "^1.0.23",
"elysia": "^1.0.27",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"typescript": "^5.4.5",
"zero-configuration": "^0.11.3"
"typescript": "^5.5.3",
"zero-configuration": "^0.16.1"
},
"trustedDependencies": [
"zero-configuration"
Expand Down
16 changes: 8 additions & 8 deletions template/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
}
},
"devDependencies": {
"@biomejs/biome": "^1.8.1",
"@playwright/test": "^1.44.1",
"@rsbuild/core": "^0.7.7",
"@rsbuild/plugin-react": "^0.7.7",
"@biomejs/biome": "^1.8.3",
"@playwright/test": "^1.45.1",
"@rsbuild/core": "^1.0.0-alpha.9",
"@rsbuild/plugin-react": "^1.0.0-alpha.9",
"@types/react": "^18",
"@types/react-dom": "^18",
"electron": "^31.0.1",
"electron": "^31.2.0",
"electron-builder": "^24.13.3",
"playwright": "^1.44.1",
"playwright": "^1.45.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"typescript": "^5.4.5",
"zero-configuration": "^0.11.3"
"typescript": "^5.5.3",
"zero-configuration": "^0.16.1"
},
"trustedDependencies": [
"zero-configuration",
Expand Down
6 changes: 3 additions & 3 deletions template/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"dependencies": {
"react": "^18.3.1",
"react-native": "^0.74.2"
"react-native": "^0.74.3"
},
"devDependencies": {
"@types/jest": "^29.5.12",
Expand All @@ -30,8 +30,8 @@
"jest": "^29.7.0",
"numic": "^2.2.0",
"react-test-renderer": "^18.3.1",
"typescript": "^5.4.5",
"zero-configuration": "^0.11.3"
"typescript": "^5.5.3",
"zero-configuration": "^0.16.1"
},
"trustedDependencies": [
"zero-configuration",
Expand Down
8 changes: 4 additions & 4 deletions template/plugin-bun/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"scripts": {
"format": "biome check --apply .",
"format": "biome check --write .",
"types": "tsc"
},
"devDependencies": {
"@biomejs/biome": "^1.8.1",
"typescript": "^5.4.5",
"zero-configuration": "^0.11.3"
"@biomejs/biome": "^1.8.3",
"typescript": "^5.5.3",
"zero-configuration": "^0.16.1"
},
"peerDependencies": {
"typescript": ">= 5"
Expand Down
8 changes: 4 additions & 4 deletions template/plugin-react/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"scripts": {
"check": "biome check --apply .",
"check": "biome check --write .",
"types": "tsc"
},
"devDependencies": {
"@biomejs/biome": "^1.8.1",
"@biomejs/biome": "^1.8.3",
"@types/react": "^18.3.3",
"typescript": "^5.4.5",
"zero-configuration": "^0.11.3"
"typescript": "^5.5.3",
"zero-configuration": "^0.16.1"
},
"peerDependencies": {
"react": ">= 18",
Expand Down
12 changes: 6 additions & 6 deletions template/web/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"scripts": {
"check": "biome check --apply .",
"check": "biome check --write .",
"start": "rsbuild dev --open",
"types": "tsc"
},
"dependencies": {
"@biomejs/biome": "^1.8.1",
"@rsbuild/core": "^0.7.7",
"@rsbuild/plugin-react": "^0.7.7",
"@biomejs/biome": "^1.8.3",
"@rsbuild/core": "^1.0.0-alpha.9",
"@rsbuild/plugin-react": "^1.0.0-alpha.9",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"typescript": "^5.4.5",
"zero-configuration": "^0.11.3"
"typescript": "^5.5.3",
"zero-configuration": "^0.16.1"
},
"trustedDependencies": [
"zero-configuration"
Expand Down
7 changes: 7 additions & 0 deletions test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ test("Doesn't add deployment files to gitignore in CI.", async () => {

expect(gitignoreFile).not.toContain('vercel.json')
expect(gitignoreFile).toContain('biome.json')

const biome = await Bun.file(join(fixturePath, 'biome.json')).json()

expect(biome.linter.rules.all).toBe(true)
expect(biome.linter.rules.style.useNamingConvention).toBe('off')
expect(biome.linter.rules.style.noInferrableTypes).toBe('off')
expect(biome.options.maxAllowedComplexity).toBeLessThanOrEqual(10)
})

test('Also parses JavaScript configuration.', async () => {
Expand Down
50 changes: 30 additions & 20 deletions test/fixture/package/package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
{
"name": "package",
"author": {
"name": "Matthias Giger"
"name": "Matthias Giger"
},
"configuration": {
"eslint": true,
"prettier": "recommended",
"biome": "recommended",
"playwright": true,
"license": "MIT",
"tsconfig": {
"compilerOptions": {
"target": "ES6"
"eslint": true,
"prettier": "recommended",
"biome": {
"extends": "ninja",
"linter": {
"rules": {
"style": {
"noInferrableTypes": "off"
}
},
"vercel": {
"github": {
"silent": true
}
},
"metro": "react-native",
"react-native": {
"name": "hairplan",
"displayName": "hairplan"
}
}
},
"playwright": true,
"license": "MIT",
"tsconfig": {
"compilerOptions": {
"target": "ES6"
}
},
"vercel": {
"github": {
"silent": true
}
},
"metro": "react-native",
"react-native": {
"name": "hairplan",
"displayName": "hairplan"
}
}
}
}

0 comments on commit c7082e5

Please sign in to comment.