Skip to content

Commit a394dbe

Browse files
feat: add eslint / prettier formatting standards
Add ESLint to docs projects Simplify lint/format commands to format (fixes) and lint (checks) a Update READMEs and PR templates Fix MDX formatting issues
1 parent 77a0c2a commit a394dbe

File tree

5 files changed

+448
-212
lines changed

5 files changed

+448
-212
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build output
5+
build/
6+
dist/
7+
.astro/
8+
9+
# Generated files
10+
*.d.ts
11+
12+
# GraphQL generated files
13+
src/pages/**/*.html
14+
15+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true,
5+
es2022: true,
6+
browser: true
7+
},
8+
extends: [
9+
'eslint:recommended',
10+
'plugin:@typescript-eslint/recommended',
11+
'plugin:astro/recommended'
12+
],
13+
parser: '@typescript-eslint/parser',
14+
parserOptions: {
15+
ecmaVersion: 2022,
16+
sourceType: 'module'
17+
},
18+
plugins: ['@typescript-eslint'],
19+
overrides: [
20+
{
21+
files: ['*.astro'],
22+
parser: 'astro-eslint-parser',
23+
parserOptions: {
24+
parser: '@typescript-eslint/parser',
25+
extraFileExtensions: ['.astro']
26+
}
27+
},
28+
{
29+
files: ['public/**/*.js'],
30+
env: {
31+
browser: true,
32+
node: false
33+
}
34+
}
35+
],
36+
rules: {
37+
'@typescript-eslint/no-unused-vars': [
38+
'error',
39+
{
40+
argsIgnorePattern: '^_',
41+
varsIgnorePattern: '^_'
42+
}
43+
],
44+
'@typescript-eslint/no-explicit-any': 'warn'
45+
}
46+
}

packages/documentation/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ $ pnpm build:docs
3030

3131
This command generates static content into the build directory and can be served using any static contents hosting service.
3232

33+
- Format code and fix linting issues:
34+
35+
```sh
36+
$ pnpm format
37+
```
38+
39+
- Check formatting and linting:
40+
41+
```sh
42+
$ pnpm lint
43+
```
44+
3345
## Editing Content
3446

3547
Starlight looks for `.md` or `.mdx` files in the `src/content/docs/` directory. Each file is exposed as a route based on its file name. Due to the nature of how Starlight deals with content and their generated URLs, all docs content lives in `/src/content/docs/`. For example, the home page of the documentation lives within the `/src/content/docs/` folder and is rendered at rafiki.dev, not rafiki.dev/docs.
@@ -112,3 +124,12 @@ import Base from '../layouts/Base.astro';
112124
```
113125

114126
Refer to the Astro documentation on [pages](https://docs.astro.build/en/core-concepts/astro-pages/) for more detailed guidance.
127+
128+
## Code Formatting
129+
130+
This project uses [Prettier](https://prettier.io/) and [ESLint](https://eslint.org/) for code formatting and linting. Before submitting a pull request, please ensure your code is properly formatted:
131+
132+
1. **Fix issues**: Run `pnpm format` to automatically fix formatting and linting issues
133+
2. **Check before pushing**: Run `pnpm lint` to verify everything passes (CI will also run this)
134+
135+
ESLint is configured to work with TypeScript and Astro files. The configuration extends recommended rules from ESLint, TypeScript ESLint, and Astro ESLint plugins.

packages/documentation/package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"build:docs": "astro build",
88
"build:docs:graphql": "spectaql config-auth.yml && spectaql config-backend.yml",
99
"preview": "astro preview",
10-
"astro": "astro"
10+
"astro": "astro",
11+
"format": "prettier --write . && eslint . --ext .js,.jsx,.ts,.tsx,.astro --fix",
12+
"lint": "prettier --check . && eslint . --ext .js,.jsx,.ts,.tsx,.astro"
1113
},
1214
"dependencies": {
1315
"@astrojs/markdown-remark": "^6.3.2",
@@ -22,5 +24,12 @@
2224
"starlight-fullview-mode": "^0.2.3",
2325
"starlight-links-validator": "^0.17.0",
2426
"starlight-versions": "^0.5.5"
27+
},
28+
"devDependencies": {
29+
"@typescript-eslint/eslint-plugin": "^7.0.0",
30+
"@typescript-eslint/parser": "^7.0.0",
31+
"astro-eslint-parser": "^1.0.0",
32+
"eslint": "^8.57.0",
33+
"eslint-plugin-astro": "^0.32.0"
2534
}
2635
}

0 commit comments

Comments
 (0)