Skip to content

Commit 0098b9d

Browse files
feat: Add biome, ESLint and Prettier with consistent formatting standards
- Add ESLint 9 and Prettier for consistent code formatting across docs repos - Configure ESLint with TypeScript and Astro support - Standardize lint and format commands across all repositories - Upgrade to ESLint 9 flat config format (eslint.config.js) - Update all ESLint and Prettier packages to latest versions - Add CI checks to enforce formatting standards
1 parent 89d4662 commit 0098b9d

File tree

11 files changed

+1634
-21
lines changed

11 files changed

+1634
-21
lines changed

.github/pull_request_template.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Changes proposed in this pull request
2+
3+
<!--
4+
Provide a succinct description of what this pull request entails.
5+
-->
6+
7+
## Context
8+
9+
<!--
10+
What were you trying to do?
11+
Link issues here - using `fixes #number`
12+
-->
13+
14+
## Checklist
15+
16+
- [ ] I have run `bun run format` to ensure code is properly formatted
17+
- [ ] I have verified that `bun run lint` passes without errors

.github/workflows/test-build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ jobs:
1717

1818
- name: Install dependencies
1919
run: bun install
20+
- name: Run ESLint
21+
run: bun run lint
2022
- name: Test build website
2123
run: bun run build

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,20 @@ All commands are run from the root of the project, from a terminal:
5252
| `bun run preview` | Preview your build locally, before deploying |
5353
| `bun run astro ...` | Run CLI commands like `astro add`, `astro check` |
5454
| `bun run astro -- --help` | Get help using the Astro CLI |
55+
| `bun run format` | Fix linting issues |
56+
| `bun run lint` | Check linting |
5557

5658
You can substitute the `bun` commands with whatever package manager of your choice uses.
5759

60+
### 🔍 Code Linting
61+
62+
This project uses [ESLint](https://eslint.org/) for code linting. Before submitting a pull request, please ensure your code passes linting:
63+
64+
1. **Fix issues**: Run `bun run format` to automatically fix linting issues
65+
2. **Check before pushing**: Run `bun run lint` to verify everything passes (CI will also run this)
66+
67+
ESLint is configured to work with TypeScript and Astro files. The configuration extends recommended rules from ESLint, TypeScript ESLint, and Astro ESLint plugins.
68+
5869
### 👀 Want to learn more?
5970

6071
Check out [Starlight’s docs](https://starlight.astro.build/), read [the Astro documentation](https://docs.astro.build), or jump into the [Astro Discord server](https://astro.build/chat).

biome.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.3.6/schema.json",
3+
"formatter": {
4+
"enabled": true,
5+
"indentStyle": "space",
6+
"indentWidth": 2,
7+
"lineWidth": 100
8+
},
9+
"linter": {
10+
"enabled": true,
11+
"rules": {
12+
"recommended": true
13+
}
14+
},
15+
"javascript": {
16+
"formatter": {
17+
"quoteStyle": "single",
18+
"semicolons": "asNeeded",
19+
"trailingCommas": "none",
20+
"jsxQuoteStyle": "single"
21+
}
22+
},
23+
"files": {
24+
"includes": [
25+
"**/*.astro",
26+
"**/*.{js,jsx,ts,tsx,json}",
27+
"!**/node_modules",
28+
"!**/dist",
29+
"!**/.astro"
30+
]
31+
},
32+
"overrides": [
33+
{
34+
"includes": ["**/*.astro"],
35+
"formatter": {
36+
"enabled": true
37+
},
38+
"linter": {
39+
"rules": {
40+
"correctness": {
41+
"noUnusedImports": "off",
42+
"noUnusedVariables": "off"
43+
}
44+
}
45+
}
46+
}
47+
]
48+
}

bun.lock

Lines changed: 1460 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eslint.config.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import eslintPluginAstro from 'eslint-plugin-astro'
2+
import tseslintPlugin from '@typescript-eslint/eslint-plugin'
3+
import tsparser from '@typescript-eslint/parser'
4+
import js from '@eslint/js'
5+
import globals from 'globals'
6+
7+
export default [
8+
{
9+
ignores: ['node_modules', 'dist', '.astro', '*.d.ts']
10+
},
11+
js.configs.recommended,
12+
{
13+
files: ['**/*.{js,mjs,ts,tsx}'],
14+
languageOptions: {
15+
globals: {
16+
...globals.node,
17+
...globals.browser
18+
},
19+
parser: tsparser,
20+
parserOptions: {
21+
ecmaVersion: 2022,
22+
sourceType: 'module'
23+
}
24+
},
25+
plugins: {
26+
'@typescript-eslint': tseslintPlugin
27+
},
28+
rules: {
29+
...tseslintPlugin.configs.recommended.rules,
30+
'@typescript-eslint/no-unused-vars': [
31+
'error',
32+
{
33+
argsIgnorePattern: '^_',
34+
varsIgnorePattern: '^_'
35+
}
36+
],
37+
'@typescript-eslint/no-explicit-any': 'warn'
38+
}
39+
},
40+
{
41+
files: ['**/*.d.ts', '**/env.d.ts'],
42+
rules: {
43+
'@typescript-eslint/triple-slash-reference': 'off'
44+
}
45+
},
46+
{
47+
files: ['*.astro'],
48+
plugins: {
49+
astro: eslintPluginAstro
50+
},
51+
languageOptions: {
52+
parser: eslintPluginAstro.parser,
53+
parserOptions: {
54+
parser: tsparser,
55+
extraFileExtensions: ['.astro']
56+
}
57+
},
58+
rules: {
59+
...eslintPluginAstro.configs.recommended.rules
60+
}
61+
}
62+
]

package.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"start": "astro dev",
66
"build": "astro build",
77
"preview": "astro preview",
8-
"astro": "astro"
8+
"astro": "astro",
9+
"format": "biome check --write . && biome format --write . && prettier --write '**/*.{md,mdx}' && eslint --max-warnings=0 --fix .",
10+
"lint": "biome check . && prettier --check '**/*.{md,mdx}' && eslint --max-warnings=0 ."
911
},
1012
"dependencies": {
1113
"@astrojs/starlight": "^0.34.4",
@@ -14,5 +16,18 @@
1416
"sharp": "^0.34.2",
1517
"starlight-fullview-mode": "^0.2.3",
1618
"starlight-links-validator": "^0.17.0"
19+
},
20+
"devDependencies": {
21+
"@biomejs/biome": "^2.3.6",
22+
"@eslint/js": "^9.32.0",
23+
"@typescript-eslint/eslint-plugin": "^8.39.0",
24+
"@typescript-eslint/parser": "^8.39.0",
25+
"astro-eslint-parser": "^1.2.2",
26+
"eslint": "^9.32.0",
27+
"eslint-config-prettier": "^10.1.8",
28+
"eslint-plugin-astro": "^1.3.1",
29+
"globals": "^16.3.0",
30+
"prettier": "^3.6.2",
31+
"prettier-plugin-astro": "^0.14.1"
1732
}
1833
}

src/components/Header.astro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
import SiteTitle from "@astrojs/starlight/components/SiteTitle.astro";
3-
import Search from "@astrojs/starlight/components/Search.astro";
4-
import ThemeSelect from "@astrojs/starlight/components/ThemeSelect.astro";
5-
import SocialIcons from "@astrojs/starlight/components/SocialIcons.astro";
2+
import SiteTitle from '@astrojs/starlight/components/SiteTitle.astro'
3+
import Search from '@astrojs/starlight/components/Search.astro'
4+
import ThemeSelect from '@astrojs/starlight/components/ThemeSelect.astro'
5+
import SocialIcons from '@astrojs/starlight/components/SocialIcons.astro'
66
---
77
<div class="header sl-flex">
88
<SiteTitle />

src/components/PageSidebar.astro

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
---
2-
import Default from '@astrojs/starlight/components/PageSidebar.astro';
2+
import Default from '@astrojs/starlight/components/PageSidebar.astro'
33
4-
const removeOverview = [
5-
'iana',
6-
]
7-
const { id, toc } = Astro.locals.starlightRoute;
8-
const noOverview = removeOverview.includes(id);
4+
const removeOverview = ['iana']
5+
const { id, toc } = Astro.locals.starlightRoute
6+
const noOverview = removeOverview.includes(id)
97
if (noOverview && toc) {
10-
Astro.locals.starlightRoute.toc = {
11-
...toc,
12-
items: toc.items.slice(1),
13-
};
8+
Astro.locals.starlightRoute.toc = {
9+
...toc,
10+
items: toc.items.slice(1)
11+
}
1412
}
1513
---
1614

src/content.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { defineCollection } from 'astro:content';
2-
import { docsLoader } from '@astrojs/starlight/loaders';
3-
import { docsSchema, i18nSchema } from '@astrojs/starlight/schema';
1+
import { defineCollection } from 'astro:content'
2+
import { docsLoader } from '@astrojs/starlight/loaders'
3+
import { docsSchema, i18nSchema } from '@astrojs/starlight/schema'
44

55
export const collections = {
66
docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
7-
i18n: defineCollection({ type: 'data', schema: i18nSchema() }),
8-
};
7+
i18n: defineCollection({ type: 'data', schema: i18nSchema() })
8+
}

0 commit comments

Comments
 (0)