@mkappelhof/biome-config 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md ADDED
@@ -0,0 +1,55 @@
1
+ # @mkappelhof/biome-config — agent instructions
2
+
3
+ This project's `biome.json` extends `@mkappelhof/biome-config`. Biome handles linting, formatting and import sorting, so do not add Prettier or ESLint alongside it.
4
+
5
+ ## Commands
6
+
7
+ - `pnpm biome check .` lints, checks formatting and checks import order.
8
+ - `pnpm biome check --write .` applies safe fixes, formats and sorts imports.
9
+ - `pnpm biome check --write <files>` does the same for specific files.
10
+
11
+ Run `pnpm biome check --write` on the files you changed before you finish a task. The task is not done while `pnpm biome check .` reports errors. Files listed in `.gitignore` are skipped.
12
+
13
+ ## Formatting (applied automatically, do not fight it)
14
+
15
+ - 2-space indentation, LF line endings, 100-character line width. An `.editorconfig` in the project takes precedence.
16
+ - Single quotes, semicolons always, trailing commas where valid in ES5, parentheses around arrow function parameters always.
17
+ - Self-closing void HTML elements (`<br />`).
18
+
19
+ ## Import order
20
+
21
+ Imports are sorted into these groups, in this order:
22
+
23
+ 1. Node/Bun built-ins (`node:fs`, `bun:test`)
24
+ 2. `react`
25
+ 3. URLs, packages and aliases
26
+ 4. *(blank line)* CSS / SCSS imports
27
+ 5. *(blank line)* SVG imports
28
+
29
+ Let `biome check --write` order imports for you. Do not order them by hand.
30
+
31
+ ## Lint rules
32
+
33
+ The `recommended` preset is enabled, plus these rules as errors:
34
+
35
+ - **No `any`** (`noExplicitAny`). Use `unknown` and narrow it, or write a proper type.
36
+ - **No `console`** (`noConsole`). Use the project's logger, or remove debug output before you finish. Allowed in `*.config.*`, `scripts/**` and `bin/**` files, where logging is normal.
37
+ - **No unused imports or variables** (`noUnusedImports`, `noUnusedVariables`). Prefix intentionally unused variables or parameters with `_`.
38
+ - **Type-only imports and exports use `type`** (`useImportType`, `useExportType`): `import type { Foo } from './foo'` or `import { type Foo, bar } from './foo'`.
39
+ - **Node built-ins use the `node:` prefix** (`useNodejsImportProtocol`): `import { readFile } from 'node:fs/promises'`.
40
+ - **Arrow functions that only return a value use a concise body** (`useConsistentArrowReturn`): `(x) => x * 2`, not `(x) => { return x * 2; }`.
41
+
42
+ Framework-specific rules (React, Next.js, test runners) are turned on automatically based on the dependencies in `package.json`. If the project's `biome.json` sets `linter.domains` explicitly (see its README), treat that as the source of truth instead.
43
+
44
+ Fix the cause of a diagnostic. Do not add `// biome-ignore` unless there is no reasonable alternative, and always give a reason: `// biome-ignore lint/<group>/<rule>: <reason>`. Do not disable rules or change formatter settings in the project's `biome.json` to get a check to pass.
45
+
46
+ ## Tool boundaries
47
+
48
+ Biome covers JS/TS/JSON (and HTML, via `experimentalFullSupportEnabled`). If the project also
49
+ lints CSS/SCSS with Stylelint (see `@mkappelhof/stylelint-config`), leave that to Stylelint —
50
+ don't add `**/*.css`/`**/*.scss` to this config's `files.includes` and don't add a Biome CSS
51
+ override to replace it.
52
+
53
+ Never run `git commit`, create a branch, or push, unless you are explicitly asked to. Leave
54
+ changes as uncommitted/staged working-tree edits and let the user commit, branch and push
55
+ themselves.
package/CHANGELOG.md ADDED
@@ -0,0 +1,44 @@
1
+ # @mkappelhof/biome-config
2
+
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 9665a73: Fix and modernise the Biome config:
8
+
9
+ - Respect `.gitignore` (VCS integration enabled). Projects without a `.gitignore` next to `biome.json` must set `"vcs": { "enabled": false }`.
10
+ - Check every file type Biome supports (CSS, JSX, `.mjs`/`.cjs`, etc.), and also ignore `build`, `out`, `coverage` and `.next`.
11
+ - Enable `noExplicitAny`, `noConsole`, `noUnusedImports`, `noUnusedVariables`, `useImportType`, `useExportType`, `useNodejsImportProtocol` and `useConsistentArrowReturn` as errors.
12
+ - Loosen the `@biomejs/biome` peer dependency to `^2.5.0`.
13
+ - Add an `exports` map (`@mkappelhof/biome-config` and `@mkappelhof/biome-config/biome` both work) and a `files` list, so only the config and docs are published.
14
+ - Remove the rollup build, which wrote JavaScript into `dist/biome.json`.
15
+ - Add `AGENTS.md`.
16
+ - Turn `noConsole` back off for `*.config.*`, `scripts/**` and `bin/**` files.
17
+ - Document how to pin `linter.domains` explicitly in a consuming project, instead of relying on Biome's dependency-based auto-detection of React/Next/test rules.
18
+ - Add a fixture-based regression test (`pnpm test`) that checks the config's custom rules and overrides actually fire.
19
+
20
+ ### Patch Changes
21
+
22
+ - 1eb73de: Add an `astro.json` preset to `@mkappelhof/ts-config`, pulled from how a real Astro site configures
23
+ TypeScript: Astro's own `strict.json` base plus this package's usual `noUncheckedIndexedAccess`,
24
+ `noImplicitOverride` and `noFallthroughCasesInSwitch`.
25
+
26
+ Also documents pinning Biome's `astro` lint domain in `@mkappelhof/biome-config`'s README, alongside
27
+ the existing `react`/`next`/`test` domain guidance.
28
+ - 58ff254: Pull in live configuration learnings from a real project:
29
+
30
+ - `@mkappelhof/biome-config`: enable `html.experimentalFullSupportEnabled`, and document in the
31
+ `AGENTS.md`/README how to pair this config with `@mkappelhof/stylelint-config` without the two
32
+ tools overlapping on the same files.
33
+ - `@mkappelhof/ts-config`: document in `AGENTS.md` that `react.json` projects define path aliases
34
+ and any extra ambient `types` (e.g. browser-extension globals) in their own `tsconfig.json`.
35
+
36
+ Also adds a new `@mkappelhof/stylelint-config` package (Stylelint config for CSS/SCSS, built on
37
+ `stylelint-config-standard` + `stylelint-config-recommended-scss`), for projects that pair Biome
38
+ with Stylelint instead of relying on Biome for styles.
39
+
40
+ ## 1.0.1
41
+
42
+ ### Patch Changes
43
+
44
+ - 4035554: Add biome config
package/README.md CHANGED
@@ -1,3 +1,114 @@
1
- # Temporary Holding Version
1
+ # Shared Biome configuration
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Linting, formatting and import sorting with [Biome](https://biomejs.dev) 2.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ pnpm add -D @mkappelhof/biome-config @biomejs/biome
9
+ ```
10
+
11
+ Create a `biome.json` in the root of your project, next to `.gitignore`:
12
+
13
+ ```JSON
14
+ {
15
+ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
16
+ "extends": ["@mkappelhof/biome-config"]
17
+ }
18
+ ```
19
+
20
+ Add scripts to `package.json`:
21
+
22
+ ```JSON
23
+ {
24
+ "scripts": {
25
+ "lint": "biome check .",
26
+ "lint:fix": "biome check --write ."
27
+ }
28
+ }
29
+ ```
30
+
31
+ ### Monorepos
32
+
33
+ Only the root `biome.json` extends this package. Nested configs in workspace packages inherit from the root:
34
+
35
+ ```JSON
36
+ {
37
+ "root": false,
38
+ "extends": "//"
39
+ }
40
+ ```
41
+
42
+ ### Without git
43
+
44
+ The config reads `.gitignore`, and Biome looks for it next to `biome.json`. If your project has no `.gitignore` there, turn VCS integration off:
45
+
46
+ ```JSON
47
+ {
48
+ "extends": ["@mkappelhof/biome-config"],
49
+ "vcs": { "enabled": false }
50
+ }
51
+ ```
52
+
53
+ ### Deterministic framework rules
54
+
55
+ Biome turns on React/Next.js/Astro/test-runner rules by sniffing your dependencies, so lint behavior can shift when you add or remove a package without touching `biome.json`. To pin it down instead, set `linter.domains` explicitly in your project's `biome.json`:
56
+
57
+ ```JSON
58
+ {
59
+ "extends": ["@mkappelhof/biome-config"],
60
+ "linter": {
61
+ "domains": {
62
+ "react": "recommended",
63
+ "next": "recommended",
64
+ "astro": "recommended",
65
+ "test": "recommended"
66
+ }
67
+ }
68
+ }
69
+ ```
70
+
71
+ The `astro` domain only catches `.astro`-specific lint rules (e.g. conflicting `set:html`/children
72
+ directives). Formatting and parsing `.astro` files at all requires `html.experimentalFullSupportEnabled`
73
+ (already on in this config — see [below](#whats-included)), since Biome treats Astro as an
74
+ HTML-superset language.
75
+
76
+ Only set the domains that apply to your project; `"none"` turns a domain off entirely. This isn't the default in `@mkappelhof/biome-config` itself, since the shared config is also used by plain Node projects that shouldn't get React/Next rules.
77
+
78
+ ### Editor
79
+
80
+ Install the Biome extension for your editor and make it the default formatter. For VS Code, put this in `.vscode/settings.json`:
81
+
82
+ ```JSON
83
+ {
84
+ "editor.defaultFormatter": "biomejs.biome",
85
+ "editor.formatOnSave": true,
86
+ "editor.codeActionsOnSave": {
87
+ "source.fixAll.biome": "explicit",
88
+ "source.organizeImports.biome": "explicit"
89
+ }
90
+ }
91
+ ```
92
+
93
+ ## What's included
94
+
95
+ - **Files:** everything Biome supports (JS/TS/JSX, JSON, CSS, HTML, GraphQL), except files in `.gitignore` and `dist`, `build`, `out`, `coverage`, `.next`, `.astro`, `.vercel` and `.turbo`.
96
+ - **Formatter:** 2 spaces, 100-character lines, single quotes, semicolons, ES5 trailing commas. An `.editorconfig` takes precedence.
97
+ - **Linter:** the `recommended` preset, plus these rules as errors: `noExplicitAny`, `noConsole`, `noUnusedImports`, `noUnusedVariables`, `useImportType`, `useExportType`, `useNodejsImportProtocol` and `useConsistentArrowReturn`. `noConsole` is off again in `*.config.*`, `scripts/**` and `bin/**` files. Framework rules (React, Next.js, tests) are turned on automatically based on your dependencies — see [below](#deterministic-framework-rules) to pin them explicitly instead.
98
+ - **HTML:** `experimentalFullSupportEnabled` is on, so Biome formats full HTML/Astro templates rather than only the parts it previously supported.
99
+ - **Imports:** sorted into groups: Node/Bun built-ins, React, packages/aliases, then stylesheets and SVGs, each after a blank line.
100
+
101
+ ## Pairing with Stylelint
102
+
103
+ Biome can format/lint CSS and SCSS, but if the project uses `@mkappelhof/stylelint-config` for
104
+ style files (recommended for SCSS-heavy projects — `@use`, nesting, etc.), don't let both tools
105
+ touch the same files. Either exclude style files from this config's `files.includes` in the
106
+ project's `biome.json`, or just don't point Stylelint and Biome at overlapping globs.
107
+
108
+ ## AI agents
109
+
110
+ This package ships an `AGENTS.md` that describes the conventions this config enforces. Reference it from your project's `AGENTS.md`:
111
+
112
+ ```md
113
+ - Follow `node_modules/@mkappelhof/biome-config/AGENTS.md`
114
+ ```
package/biome.json ADDED
@@ -0,0 +1,128 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/2.5.15/schema.json",
3
+ "vcs": {
4
+ "enabled": true,
5
+ "clientKind": "git",
6
+ "useIgnoreFile": true
7
+ },
8
+ "files": {
9
+ "ignoreUnknown": true,
10
+ "includes": [
11
+ "**",
12
+ "!**/.vscode",
13
+ "!**/dist",
14
+ "!**/build",
15
+ "!**/out",
16
+ "!**/coverage",
17
+ "!**/.next",
18
+ "!**/.astro",
19
+ "!**/.vercel",
20
+ "!**/.turbo",
21
+ "!**/pnpm-lock.yaml"
22
+ ]
23
+ },
24
+ "formatter": {
25
+ "enabled": true,
26
+ "formatWithErrors": false,
27
+ "indentStyle": "space",
28
+ "indentWidth": 2,
29
+ "lineEnding": "lf",
30
+ "lineWidth": 100,
31
+ "attributePosition": "auto",
32
+ "bracketSameLine": false,
33
+ "bracketSpacing": true,
34
+ "expand": "auto",
35
+ "useEditorconfig": true
36
+ },
37
+ "linter": {
38
+ "enabled": true,
39
+ "rules": {
40
+ "preset": "recommended",
41
+ "correctness": {
42
+ "noUnusedImports": "error",
43
+ "noUnusedVariables": "error"
44
+ },
45
+ "suspicious": {
46
+ "noConsole": "error",
47
+ "noExplicitAny": "error"
48
+ },
49
+ "style": {
50
+ "useImportType": "error",
51
+ "useExportType": "error",
52
+ "useNodejsImportProtocol": "error",
53
+ "useConsistentArrowReturn": "error"
54
+ }
55
+ }
56
+ },
57
+ "javascript": {
58
+ "formatter": {
59
+ "quoteProperties": "asNeeded",
60
+ "trailingCommas": "es5",
61
+ "semicolons": "always",
62
+ "arrowParentheses": "always",
63
+ "bracketSameLine": false,
64
+ "quoteStyle": "single",
65
+ "attributePosition": "auto",
66
+ "bracketSpacing": true
67
+ }
68
+ },
69
+ "html": {
70
+ "experimentalFullSupportEnabled": true,
71
+ "formatter": {
72
+ "enabled": true,
73
+ "selfCloseVoidElements": "always"
74
+ }
75
+ },
76
+ "overrides": [
77
+ {
78
+ "includes": [
79
+ "**/*.config.*",
80
+ "**/scripts/**",
81
+ "**/bin/**"
82
+ ],
83
+ "linter": {
84
+ "rules": {
85
+ "suspicious": {
86
+ "noConsole": "off"
87
+ }
88
+ }
89
+ }
90
+ }
91
+ ],
92
+ "assist": {
93
+ "enabled": true,
94
+ "actions": {
95
+ "source": {
96
+ "organizeImports": {
97
+ "level": "on",
98
+ "options": {
99
+ "groups": [
100
+ [
101
+ ":NODE:",
102
+ ":BUN:"
103
+ ],
104
+ "react",
105
+ [
106
+ ":URL:",
107
+ ":PATH:",
108
+ ":PACKAGE_WITH_PROTOCOL:",
109
+ ":PACKAGE:",
110
+ ":ALIAS:",
111
+ "!**/*.css",
112
+ "!**/*.scss",
113
+ "!**/*.svg"
114
+ ],
115
+ ":BLANK_LINE:",
116
+ [
117
+ "**/*.css",
118
+ "**/*.scss"
119
+ ],
120
+ ":BLANK_LINE:",
121
+ "**/*.svg"
122
+ ]
123
+ }
124
+ }
125
+ }
126
+ }
127
+ }
128
+ }
package/package.json CHANGED
@@ -1,6 +1,36 @@
1
1
  {
2
2
  "name": "@mkappelhof/biome-config",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0",
4
+ "description": "Shared Biome configuration (linting + formatting)",
5
+ "main": "biome.json",
6
+ "exports": {
7
+ ".": "./biome.json",
8
+ "./biome": "./biome.json",
9
+ "./package.json": "./package.json"
10
+ },
11
+ "files": [
12
+ "biome.json",
13
+ "AGENTS.md",
14
+ "README.md",
15
+ "CHANGELOG.md"
16
+ ],
17
+ "license": "MIT",
18
+ "repository": "git@github.com:mkappelhof/frontend-tools.git",
19
+ "author": "Maurice Kappelhof <maurice@mauricekappelhof.nl>",
20
+ "scripts": {
21
+ "lint": "biome check --vcs-enabled=false biome.json package.json README.md AGENTS.md",
22
+ "test": "node test/run.mjs"
23
+ },
24
+ "peerDependencies": {
25
+ "@biomejs/biome": "^2.5.0"
26
+ },
27
+ "devDependencies": {
28
+ "@biomejs/biome": "2.5.15"
29
+ },
30
+ "keywords": [
31
+ "biome",
32
+ "lint",
33
+ "format",
34
+ "config"
35
+ ]
6
36
  }