@mkappelhof/biome-config 0.0.0-stage → 1.1.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,67 @@
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 --unsafe .` also applies unsafe fixes (e.g. `useBlockStatements`
10
+ wrapping a bare `if (x) return;` in braces). Review the diff — unsafe fixes are low-risk here,
11
+ not unreviewed.
12
+ - `pnpm biome check --write <files>` (optionally with `--unsafe`) does the same for specific files.
13
+
14
+ Run `pnpm biome check --write --unsafe` 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.
15
+
16
+ ## Formatting (applied automatically, do not fight it)
17
+
18
+ - 2-space indentation, LF line endings, 100-character line width. An `.editorconfig` in the project takes precedence.
19
+ - Single quotes, semicolons always, trailing commas where valid in ES5, parentheses around arrow function parameters always.
20
+ - Self-closing void HTML elements (`<br />`).
21
+
22
+ ## Import order
23
+
24
+ Imports are sorted into these groups, in this order:
25
+ 1. Node/Bun built-ins (`node:fs`, `bun:test`)
26
+ 2. `react`
27
+ 3. URLs, packages and aliases
28
+ 4. _(blank line)_ CSS / SCSS imports
29
+ 5. _(blank line)_ SVG imports
30
+
31
+ Let `biome check --write` order imports for you. Do not order them by hand.
32
+
33
+ ## Lint rules
34
+
35
+ The `recommended` preset is enabled, plus these rules as errors:
36
+ - **No `any`** (`noExplicitAny`). Use `unknown` and narrow it, or write a proper type.
37
+ - **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.
38
+ - **No unused imports or variables** (`noUnusedImports`, `noUnusedVariables`). Prefix intentionally unused variables or parameters with `_`.
39
+ - **Type-only imports and exports use `type`** (`useImportType`, `useExportType`): `import type { Foo } from './foo'` or `import { type Foo, bar } from './foo'`.
40
+ - **Node built-ins use the `node:` prefix** (`useNodejsImportProtocol`): `import { readFile } from 'node:fs/promises'`.
41
+ - **Arrow functions that only return a value use a concise body** (`useConsistentArrowReturn`): `(x) => x * 2`, not `(x) => { return x * 2; }`.
42
+ - **Braceless single-statement bodies are not allowed** (`useBlockStatements`): write `if (!x) { throw new Error(); }`, not `if (!x) throw new Error();` or `if (x) return;`. Applies to `if`/`else`, loops and similar. The auto-fix for this one is unsafe (see Commands above), not unavailable.
43
+
44
+ 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.
45
+
46
+ 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.
47
+
48
+ ## CSS/SCSS
49
+
50
+ Biome 2.6+ fully parses, formats and lints `.scss` files (not just CSS Modules), and
51
+ `files.includes` matches them by default. On top of `recommended`, these are pinned as errors:
52
+ `useGenericFontNames`, `noInvalidDirectionInLinearGradient`, `noInvalidGridAreas`,
53
+ `noInvalidPositionAtImportRule`, `noMissingVarFunction`, `noUnknownMediaFeatureName`,
54
+ `noUnknownProperty`, `noUnknownPseudoClass`, `noUnknownPseudoElement`, `noUnknownTypeSelector`,
55
+ `noUnknownUnit`, `noUnmatchableAnbSelector`, `noDeprecatedMediaType`, `noDuplicateAtImportRules`,
56
+ `noDuplicateCustomProperties`, `noDuplicateFontNames`, `noDuplicateProperties`,
57
+ `noDuplicateSelectorsKeyframeBlock`, `noEmptyBlock`, `noEmptySource`, `noImportantInKeyframe` and
58
+ `noIrregularWhitespace`. Use `// biome-ignore lint/<group>/<rule>: <reason>` the same as for JS/TS,
59
+ not a `/* stylelint-disable */` comment.
60
+
61
+ ## Tool boundaries
62
+
63
+ Biome covers JS/TS/JSON/CSS/SCSS (and HTML, via `experimentalFullSupportEnabled`). If the project
64
+ also lints CSS/SCSS with Stylelint (see `@mkappelhof/stylelint-config`) rather than relying on
65
+ Biome's CSS rules, the project's own `biome.json` must exclude style files from this config's
66
+ `files.includes` (`"!**/*.css"`, `"!**/*.scss"`) so the two tools don't both process them — check
67
+ there before assuming Biome owns `.scss` files in a given project.
package/CHANGELOG.md ADDED
@@ -0,0 +1,57 @@
1
+ # @mkappelhof/biome-config
2
+
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 3c4c6b4: Enable `useBlockStatements` so braceless single-statement bodies (`if (!x) throw ...;`, `if (x) return;`) are flagged. Its fix is unsafe, so apply it with `biome check --write --unsafe` rather than plain `--write`.
8
+ - 3c4c6b4: Bump Biome to 2.6.2, which adds full SCSS support (not just CSS Modules) to Biome's own parser, formatter and linter. Pin the CSS/SCSS lint rules that mirror `@mkappelhof/stylelint-config`'s rule set (`noUnknownProperty`, `noDuplicateProperties`, `noEmptyBlock`, etc.) as explicit errors, on top of the `recommended` preset that already covers most of them. `@mkappelhof/stylelint-config` is unchanged and still recommended for SCSS-heavy projects, since Biome's CSS linter doesn't yet cover SCSS-specific or stylistic rules.
9
+
10
+ ## 1.0.1
11
+
12
+ ### Patch Changes
13
+
14
+ - eb2577f: Add new configs
15
+
16
+ ## 2.0.0
17
+
18
+ ### Major Changes
19
+
20
+ - 9665a73: Fix and modernise the Biome config:
21
+
22
+ - Respect `.gitignore` (VCS integration enabled). Projects without a `.gitignore` next to `biome.json` must set `"vcs": { "enabled": false }`.
23
+ - Check every file type Biome supports (CSS, JSX, `.mjs`/`.cjs`, etc.), and also ignore `build`, `out`, `coverage` and `.next`.
24
+ - Enable `noExplicitAny`, `noConsole`, `noUnusedImports`, `noUnusedVariables`, `useImportType`, `useExportType`, `useNodejsImportProtocol` and `useConsistentArrowReturn` as errors.
25
+ - Loosen the `@biomejs/biome` peer dependency to `^2.5.0`.
26
+ - 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.
27
+ - Remove the rollup build, which wrote JavaScript into `dist/biome.json`.
28
+ - Add `AGENTS.md`.
29
+ - Turn `noConsole` back off for `*.config.*`, `scripts/**` and `bin/**` files.
30
+ - 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.
31
+ - Add a fixture-based regression test (`pnpm test`) that checks the config's custom rules and overrides actually fire.
32
+
33
+ ### Patch Changes
34
+
35
+ - 1eb73de: Add an `astro.json` preset to `@mkappelhof/ts-config`, pulled from how a real Astro site configures
36
+ TypeScript: Astro's own `strict.json` base plus this package's usual `noUncheckedIndexedAccess`,
37
+ `noImplicitOverride` and `noFallthroughCasesInSwitch`.
38
+
39
+ Also documents pinning Biome's `astro` lint domain in `@mkappelhof/biome-config`'s README, alongside
40
+ the existing `react`/`next`/`test` domain guidance.
41
+ - 58ff254: Pull in live configuration learnings from a real project:
42
+
43
+ - `@mkappelhof/biome-config`: enable `html.experimentalFullSupportEnabled`, and document in the
44
+ `AGENTS.md`/README how to pair this config with `@mkappelhof/stylelint-config` without the two
45
+ tools overlapping on the same files.
46
+ - `@mkappelhof/ts-config`: document in `AGENTS.md` that `react.json` projects define path aliases
47
+ and any extra ambient `types` (e.g. browser-extension globals) in their own `tsconfig.json`.
48
+
49
+ Also adds a new `@mkappelhof/stylelint-config` package (Stylelint config for CSS/SCSS, built on
50
+ `stylelint-config-standard` + `stylelint-config-recommended-scss`), for projects that pair Biome
51
+ with Stylelint instead of relying on Biome for styles.
52
+
53
+ ## 1.0.1
54
+
55
+ ### Patch Changes
56
+
57
+ - 4035554: Add biome config
package/README.md CHANGED
@@ -1,3 +1,125 @@
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, SCSS, Markdown, YAML, 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:
98
+ - JS/TS: `noExplicitAny`, `noConsole`, `noUnusedImports`, `noUnusedVariables`, `useImportType`, `useExportType`, `useNodejsImportProtocol`, `useConsistentArrowReturn` and `useBlockStatements` (no braceless `if (x) return;`/`if (!x) throw ...;` — its fix is unsafe, so run `biome check --write --unsafe` to apply it). `noConsole` is off again in `*.config.*`, `scripts/**` and `bin/**` files.
99
+ - CSS/SCSS: `useGenericFontNames`, `noInvalidDirectionInLinearGradient`, `noInvalidGridAreas`, `noInvalidPositionAtImportRule`, `noMissingVarFunction`, `noUnknownMediaFeatureName`, `noUnknownProperty`, `noUnknownPseudoClass`, `noUnknownPseudoElement`, `noUnknownTypeSelector`, `noUnknownUnit`, `noUnmatchableAnbSelector`, `noDeprecatedMediaType`, `noDuplicateAtImportRules`, `noDuplicateCustomProperties`, `noDuplicateFontNames`, `noDuplicateProperties`, `noDuplicateSelectorsKeyframeBlock`, `noEmptyBlock`, `noEmptySource`, `noImportantInKeyframe` and `noIrregularWhitespace` — these are every rule Biome 2.6+ ships with a direct equivalent to `@mkappelhof/stylelint-config`'s rule set (`stylelint-config-standard` + `stylelint-config-recommended-scss`), most already in the `recommended` preset but pinned explicitly here.
100
+ - Framework rules (React, Next.js, tests) are turned on automatically based on your dependencies — see [below](#deterministic-framework-rules) to pin them explicitly instead.
101
+ - **HTML:** `experimentalFullSupportEnabled` is on, so Biome formats full HTML/Astro templates rather than only the parts it previously supported.
102
+ - **Imports:** sorted into groups: Node/Bun built-ins, React, packages/aliases, then stylesheets and SVGs, each after a blank line.
103
+
104
+ ## Pairing with Stylelint
105
+
106
+ As of Biome 2.6, SCSS support is no longer limited to CSS Modules — Biome fully parses, formats
107
+ and lints `.scss` files, and `files.includes` matches them by default (no opt-in needed). If the
108
+ project also uses `@mkappelhof/stylelint-config`, the two tools will now process the same files
109
+ unless you stop one of them: exclude style files from this config's `files.includes` in the
110
+ project's `biome.json` (`"!**/*.css"`, `"!**/*.scss"`), or don't point Stylelint at files Biome
111
+ already covers.
112
+
113
+ `@mkappelhof/stylelint-config` still covers more ground — SCSS-specific checks (`scss/*` rules,
114
+ `@use`/`@mixin`/`@include` correctness) and most stylistic rules (empty-line conventions, color
115
+ notation, quoting, etc.) that Biome's CSS linter doesn't have an equivalent for yet — so for new
116
+ SCSS-heavy projects, or any project not yet on Biome 2.6+, keep using it instead of relying on
117
+ Biome alone.
118
+
119
+ ## AI agents
120
+
121
+ This package ships an `AGENTS.md` that describes the conventions this config enforces. Reference it from your project's `AGENTS.md`:
122
+
123
+ ```md
124
+ - Follow `node_modules/@mkappelhof/biome-config/AGENTS.md`
125
+ ```
package/biome.json ADDED
@@ -0,0 +1,144 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/2.6.2/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
+ "a11y": {
42
+ "useGenericFontNames": "error"
43
+ },
44
+ "correctness": {
45
+ "noUnusedImports": "error",
46
+ "noUnusedVariables": "error",
47
+ "noInvalidDirectionInLinearGradient": "error",
48
+ "noInvalidGridAreas": "error",
49
+ "noInvalidPositionAtImportRule": "error",
50
+ "noMissingVarFunction": "error",
51
+ "noUnknownMediaFeatureName": "error",
52
+ "noUnknownProperty": "error",
53
+ "noUnknownPseudoClass": "error",
54
+ "noUnknownPseudoElement": "error",
55
+ "noUnknownTypeSelector": "error",
56
+ "noUnknownUnit": "error",
57
+ "noUnmatchableAnbSelector": "error"
58
+ },
59
+ "suspicious": {
60
+ "noConsole": "error",
61
+ "noExplicitAny": "error",
62
+ "noDeprecatedMediaType": "error",
63
+ "noDuplicateAtImportRules": "error",
64
+ "noDuplicateCustomProperties": "error",
65
+ "noDuplicateFontNames": "error",
66
+ "noDuplicateProperties": "error",
67
+ "noDuplicateSelectorsKeyframeBlock": "error",
68
+ "noEmptyBlock": "error",
69
+ "noEmptySource": "error",
70
+ "noImportantInKeyframe": "error",
71
+ "noIrregularWhitespace": "error",
72
+ "noShorthandPropertyOverrides": "error"
73
+ },
74
+ "style": {
75
+ "useImportType": "error",
76
+ "useExportType": "error",
77
+ "useNodejsImportProtocol": "error",
78
+ "useConsistentArrowReturn": "error",
79
+ "useBlockStatements": "error"
80
+ }
81
+ }
82
+ },
83
+ "javascript": {
84
+ "formatter": {
85
+ "quoteProperties": "asNeeded",
86
+ "trailingCommas": "es5",
87
+ "semicolons": "always",
88
+ "arrowParentheses": "always",
89
+ "bracketSameLine": false,
90
+ "quoteStyle": "single",
91
+ "attributePosition": "auto",
92
+ "bracketSpacing": true
93
+ }
94
+ },
95
+ "html": {
96
+ "experimentalFullSupportEnabled": true,
97
+ "formatter": {
98
+ "enabled": true,
99
+ "selfCloseVoidElements": "always"
100
+ }
101
+ },
102
+ "overrides": [
103
+ {
104
+ "includes": ["**/*.config.*", "**/scripts/**", "**/bin/**"],
105
+ "linter": {
106
+ "rules": {
107
+ "suspicious": {
108
+ "noConsole": "off"
109
+ }
110
+ }
111
+ }
112
+ }
113
+ ],
114
+ "assist": {
115
+ "enabled": true,
116
+ "actions": {
117
+ "source": {
118
+ "organizeImports": {
119
+ "level": "on",
120
+ "options": {
121
+ "groups": [
122
+ [":NODE:", ":BUN:"],
123
+ "react",
124
+ [
125
+ ":URL:",
126
+ ":PATH:",
127
+ ":PACKAGE_WITH_PROTOCOL:",
128
+ ":PACKAGE:",
129
+ ":ALIAS:",
130
+ "!**/*.css",
131
+ "!**/*.scss",
132
+ "!**/*.svg"
133
+ ],
134
+ ":BLANK_LINE:",
135
+ ["**/*.css", "**/*.scss"],
136
+ ":BLANK_LINE:",
137
+ "**/*.svg"
138
+ ]
139
+ }
140
+ }
141
+ }
142
+ }
143
+ }
144
+ }
package/package.json CHANGED
@@ -1,6 +1,26 @@
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"
6
- }
3
+ "version": "1.1.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": ["biome.json", "AGENTS.md", "README.md", "CHANGELOG.md"],
12
+ "license": "MIT",
13
+ "repository": "git@github.com:mkappelhof/frontend-tools.git",
14
+ "author": "Maurice Kappelhof <maurice@mauricekappelhof.nl>",
15
+ "scripts": {
16
+ "lint": "biome check --vcs-enabled=false biome.json package.json README.md AGENTS.md",
17
+ "test": "node test/run.mjs"
18
+ },
19
+ "peerDependencies": {
20
+ "@biomejs/biome": "^2.6.0"
21
+ },
22
+ "devDependencies": {
23
+ "@biomejs/biome": "2.6.2"
24
+ },
25
+ "keywords": ["biome", "lint", "format", "config"]
26
+ }