From c7082e5b8ca8220ea4d150d1c7c36516b3c4a557 Mon Sep 17 00:00:00 2001 From: Matthias Giger Date: Fri, 12 Jul 2024 18:37:36 +0200 Subject: [PATCH] fix(configuration): update templates and improve Biome configuration release-npm --- configuration/biome.ts | 80 ++++++++++++++++++------------ template/default/package.json | 10 ++-- template/desktop/package.json | 16 +++--- template/mobile/package.json | 6 +-- template/plugin-bun/package.json | 8 +-- template/plugin-react/package.json | 8 +-- template/web/package.json | 12 ++--- test/basic.test.ts | 7 +++ test/fixture/package/package.json | 50 +++++++++++-------- 9 files changed, 116 insertions(+), 81 deletions(-) diff --git a/configuration/biome.ts b/configuration/biome.ts index 26dde14..652083b 100644 --- a/configuration/biome.ts +++ b/configuration/biome.ts @@ -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. }, }), } diff --git a/template/default/package.json b/template/default/package.json index 95a912e..0adcadb 100644 --- a/template/default/package.json +++ b/template/default/package.json @@ -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" diff --git a/template/desktop/package.json b/template/desktop/package.json index e3a7965..80a50b0 100644 --- a/template/desktop/package.json +++ b/template/desktop/package.json @@ -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", diff --git a/template/mobile/package.json b/template/mobile/package.json index 8c6b690..b97dadf 100644 --- a/template/mobile/package.json +++ b/template/mobile/package.json @@ -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", @@ -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", diff --git a/template/plugin-bun/package.json b/template/plugin-bun/package.json index 196e7dd..54b1791 100644 --- a/template/plugin-bun/package.json +++ b/template/plugin-bun/package.json @@ -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" diff --git a/template/plugin-react/package.json b/template/plugin-react/package.json index f78edec..86cae1a 100644 --- a/template/plugin-react/package.json +++ b/template/plugin-react/package.json @@ -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", diff --git a/template/web/package.json b/template/web/package.json index c8974a7..d961597 100644 --- a/template/web/package.json +++ b/template/web/package.json @@ -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" diff --git a/test/basic.test.ts b/test/basic.test.ts index c73ad9a..1afd0a2 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -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 () => { diff --git a/test/fixture/package/package.json b/test/fixture/package/package.json index 3f5e332..fe68222 100644 --- a/test/fixture/package/package.json +++ b/test/fixture/package/package.json @@ -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" + } } -} + } + \ No newline at end of file