Skip to content

Commit 03cd285

Browse files
Add 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 2135c28 commit 03cd285

File tree

7 files changed

+702
-2
lines changed

7 files changed

+702
-2
lines changed

.github/pull_request_template.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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
18+
19+

.github/workflows/lint.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
lint:
13+
name: Run ESLint
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: oven-sh/setup-bun@v1
18+
- name: Install dependencies
19+
run: bun install
20+
- name: Run ESLint
21+
run: bun run lint
22+
23+

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,17 @@ git clone https://github.com/interledger/docs-styleguide.git
6060
```
6161

6262
3. After you're done with your changes and have tested that all is well, feel free to make a pull request and it will get reviewed, and hopefully merged into the source code. The version will get bumped and all the sites will have to make an update to their dependencies as well.
63+
64+
### 🔍 Code Linting
65+
66+
This project uses [ESLint](https://eslint.org/) for code linting. Before submitting a pull request, please ensure your code passes linting:
67+
68+
1. **Fix issues**: Run `bun run format` to automatically fix linting issues
69+
2. **Check before pushing**: Run `bun run lint` to verify everything passes (CI will also run this)
70+
71+
ESLint is configured to work with TypeScript and Astro files. The configuration extends recommended rules from ESLint, TypeScript ESLint, and Astro ESLint plugins.
72+
73+
| Command | Action |
74+
| :--------------- | :-------------------------------- |
75+
| `bun run format` | Fix linting issues |
76+
| `bun run lint` | Check linting |

bun.lock

Lines changed: 570 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: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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"],
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+
];
63+

package.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"index.ts"
1212
],
1313
"scripts": {
14-
"test": "echo \"Error: no test specified\" && exit 1"
14+
"test": "echo \"Error: no test specified\" && exit 1",
15+
"format": "eslint . --fix",
16+
"lint": "eslint ."
1517
},
1618
"author": "Interledger <tech@interledger.org>",
1719
"license": "ISC",
@@ -21,5 +23,14 @@
2123
},
2224
"dependencies": {
2325
"mermaid": "^11.8.0"
26+
},
27+
"devDependencies": {
28+
"@eslint/js": "^9.32.0",
29+
"@typescript-eslint/eslint-plugin": "^8.39.0",
30+
"@typescript-eslint/parser": "^8.39.0",
31+
"astro-eslint-parser": "^1.2.2",
32+
"eslint": "^9.32.0",
33+
"eslint-plugin-astro": "^1.3.1",
34+
"globals": "^16.3.0"
2435
}
2536
}

src/components/MermaidWrapper.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ button:hover span {
6767
const url = URL.createObjectURL(blob)
6868
const win = open(url)
6969
if (win) {
70-
win.onload = (event) => URL.revokeObjectURL(url);
70+
win.onload = (_event) => URL.revokeObjectURL(url);
7171
}
7272
}
7373

0 commit comments

Comments
 (0)