Skip to content

Commit 39f8f9e

Browse files
Add ESLint and Prettier config (#104)
* add eslint/prettier config * eslint prettier config * lint format mdx * lint format mdx * lintformat * lint prettier file * Update src/content/docs/content/rafiki.mdx Co-authored-by: Anca Matei <98110730+Anca2022@users.noreply.github.com> * Update src/content/docs/content/starlight.mdx Co-authored-by: Anca Matei <98110730+Anca2022@users.noreply.github.com> * Update src/content/docs/index.mdx Co-authored-by: Anca Matei <98110730+Anca2022@users.noreply.github.com> * Update src/content/docs/shared/linkout.mdx Co-authored-by: Anca Matei <98110730+Anca2022@users.noreply.github.com> * Update src/content/docs/shared/removeoverview.mdx Co-authored-by: Anca Matei <98110730+Anca2022@users.noreply.github.com> * Update src/content/docs/shared/linkout.mdx Co-authored-by: Anca Matei <98110730+Anca2022@users.noreply.github.com> * Update src/content/docs/shared/linkout.mdx Co-authored-by: Anca Matei <98110730+Anca2022@users.noreply.github.com> * Update src/content/docs/shared/linkout.mdx Co-authored-by: Anca Matei <98110730+Anca2022@users.noreply.github.com> * Update src/content/docs/shared/linkout.mdx Co-authored-by: Anca Matei <98110730+Anca2022@users.noreply.github.com> * fix: readme and contibuting and worfkflow * fix ignore tags * fix codeblock * pnpm format * changing jsx codeblocks to mdx * npm format * force mdx format * pnpm lock * fix line block * change mdx to jsx * add prettier ignore * Update src/content/docs/content/global.mdx Co-authored-by: Anca Matei <98110730+Anca2022@users.noreply.github.com> * Update src/content/docs/shared/mermaidwrapper.mdx Co-authored-by: Anca Matei <98110730+Anca2022@users.noreply.github.com> * Update src/content/docs/shared/disclosure.mdx Co-authored-by: Anca Matei <98110730+Anca2022@users.noreply.github.com> * Update src/content/docs/shared/mermaidwrapper.mdx Co-authored-by: Anca Matei <98110730+Anca2022@users.noreply.github.com> * prettier ignore * multiline array --------- Co-authored-by: Anca Matei <98110730+Anca2022@users.noreply.github.com> Co-authored-by: Anca Matei <ancamatei2012@gmail.com>
1 parent ba06dc5 commit 39f8f9e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+7057
-374
lines changed

.github/pull_request_template.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ Provide a succinct description of what this pull request entails.
1010
What were you trying to do?
1111
Link issues here - using `fixes #number`
1212
-->
13+
14+
## Checklist
15+
16+
- [ ] I have run `bun run format` (or `bun run lint`) to check formatting and linting

.github/workflows/test-build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ jobs:
1616
- uses: oven-sh/setup-bun@v1
1717
- name: Install dependencies
1818
run: bun install
19+
- name: Check formatting and linting
20+
run: bun run lint
1921
- name: Test build website
2022
run: bun run build

.prettierignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.github
2+
.astro
3+
node_modules
4+
public
5+
dist
6+
**/*.min.css
7+
**/*.min.js
8+

.prettierrc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"trailingComma": "none",
5+
"plugins": ["prettier-plugin-astro"],
6+
"overrides": [
7+
{
8+
"files": "**/*.astro",
9+
"options": {
10+
"parser": "astro"
11+
}
12+
},
13+
{
14+
"files": "**/*.mdx",
15+
"options": {
16+
"parser": "mdx"
17+
}
18+
}
19+
]
20+
}
21+
22+
23+

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ curl -fsSL https://bun.sh/install | bash
3939

4040
All commands are run from the root of the project, from a terminal:
4141

42-
| Command | Action |
43-
| :------------------------ | :----------------------------------------------- |
44-
| `bun install` | Installs dependencies |
45-
| `bun run start` | Starts local dev server at `localhost:1105` |
46-
| `bun run build` | Build your production site to `./dist/` |
47-
| `bun run preview` | Preview your build locally, before deploying |
48-
| `bun run astro ...` | Run CLI commands like `astro add`, `astro check` |
49-
| `bun run astro -- --help` | Get help using the Astro CLI |
42+
| Command | Action |
43+
| :------------------------ | :-------------------------------------------------- |
44+
| `bun install` | Installs dependencies |
45+
| `bun run start` | Starts local dev server at `localhost:1105` |
46+
| `bun run build` | Build your production site to `./dist/` |
47+
| `bun run preview` | Preview your build locally, before deploying |
48+
| `bun run astro ...` | Run CLI commands like `astro add`, `astro check` |
49+
| `bun run astro -- --help` | Get help using the Astro CLI |
50+
| `bun run format` | Format and auto-fix code with Prettier & ESLint |
51+
| `bun run lint` | Check formatting and linting without making changes |
5052

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

astro.config.mjs

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,82 @@
1-
import { defineConfig } from "astro/config";
2-
import starlight from "@astrojs/starlight";
3-
import remarkMath from "remark-math";
4-
import rehypeMathjax from "rehype-mathjax";
5-
import starlightLinksValidator from "starlight-links-validator";
6-
import starlightFullViewMode from "starlight-fullview-mode";
1+
import { defineConfig } from 'astro/config'
2+
import starlight from '@astrojs/starlight'
3+
import remarkMath from 'remark-math'
4+
import rehypeMathjax from 'rehype-mathjax'
5+
import starlightLinksValidator from 'starlight-links-validator'
6+
import starlightFullViewMode from 'starlight-fullview-mode'
77

88
// https://astro.build/config
99
export default defineConfig({
10-
site: "https://interledger.net",
10+
site: 'https://interledger.net',
1111
markdown: {
1212
remarkPlugins: [remarkMath],
13-
rehypePlugins: [rehypeMathjax],
13+
rehypePlugins: [rehypeMathjax]
1414
},
1515
integrations: [
1616
starlight({
17-
title: "Docs style guide",
18-
description: "The style guide for all Interledger documentation sites. Because we love consistency.",
17+
title: 'Docs style guide',
18+
description:
19+
'The style guide for all Interledger documentation sites. Because we love consistency.',
1920
customCss: [
20-
"./node_modules/@interledger/docs-design-system/src/styles/teal-theme.css",
21-
"./node_modules/@interledger/docs-design-system/src/styles/ilf-docs.css",
21+
'./node_modules/@interledger/docs-design-system/src/styles/teal-theme.css',
22+
'./node_modules/@interledger/docs-design-system/src/styles/ilf-docs.css'
2223
],
2324
plugins: [starlightLinksValidator(), starlightFullViewMode()],
2425
expressiveCode: {
2526
styleOverrides: {
26-
borderColor: "transparent",
27-
borderRadius: "var(--border-radius)",
28-
},
27+
borderColor: 'transparent',
28+
borderRadius: 'var(--border-radius)'
29+
}
2930
},
30-
social: [{ icon: "github", label: "GitHub", href: "https://github.com/interledger/docs-styleguide" }],
31+
social: [
32+
{
33+
icon: 'github',
34+
label: 'GitHub',
35+
href: 'https://github.com/interledger/docs-styleguide'
36+
}
37+
],
3138
components: {
32-
Header: "./src/components/Header.astro",
39+
Header: './src/components/Header.astro'
3340
},
3441
sidebar: [
3542
{
36-
label: "Overview of doc styles",
37-
link: "/",
43+
label: 'Overview of doc styles',
44+
link: '/'
3845
},
3946
{
40-
label: "Style guides",
47+
label: 'Style guides',
4148
autogenerate: {
42-
directory: "content",
43-
},
49+
directory: 'content'
50+
}
4451
},
4552
{
46-
label: "Classes, styles, HTML, etc",
53+
label: 'Classes, styles, HTML, etc',
4754
autogenerate: {
48-
directory: "classes",
49-
},
55+
directory: 'classes'
56+
}
5057
},
5158
{
52-
label: "Shared Components",
59+
label: 'Shared Components',
5360
autogenerate: {
54-
directory: "shared",
55-
},
61+
directory: 'shared'
62+
}
5663
},
5764
{
58-
label: "Open Payments Components",
65+
label: 'Open Payments Components',
5966
autogenerate: {
60-
directory: "oppm",
61-
},
67+
directory: 'oppm'
68+
}
6269
},
6370
{
64-
label: "Web Monetization Components",
71+
label: 'Web Monetization Components',
6572
autogenerate: {
66-
directory: "webm",
67-
},
68-
},
69-
],
70-
}),
73+
directory: 'webm'
74+
}
75+
}
76+
]
77+
})
7178
],
7279
server: {
73-
port: 1105,
74-
},
75-
});
80+
port: 1105
81+
}
82+
})

eslint.config.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import js from '@eslint/js'
2+
import globals from 'globals'
3+
import tseslint from 'typescript-eslint'
4+
import { defineConfig, globalIgnores } from 'eslint/config'
5+
import eslintConfigPrettier from 'eslint-config-prettier/flat'
6+
import eslintPluginAstro from 'eslint-plugin-astro'
7+
8+
export default defineConfig([
9+
{
10+
files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
11+
plugins: { js },
12+
extends: ['js/recommended'],
13+
languageOptions: { globals: { ...globals.browser, ...globals.node } }
14+
},
15+
tseslint.configs.recommended,
16+
eslintPluginAstro.configs.recommended,
17+
globalIgnores(['dist', '.astro', 'node_modules', 'public', '**/*.min.js']),
18+
{
19+
rules: {
20+
'no-console': 'error',
21+
'@typescript-eslint/no-unused-vars': [
22+
'error',
23+
{ argsIgnorePattern: '^_' }
24+
],
25+
'@typescript-eslint/no-explicit-any': 'error',
26+
'astro/no-set-text-directive': 'error'
27+
}
28+
},
29+
eslintConfigPrettier
30+
])

package.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"start": "astro dev",
77
"build": "astro build",
88
"preview": "astro preview",
9-
"astro": "astro"
9+
"astro": "astro",
10+
"format": "prettier --write '**/*.{js,mjs,ts,tsx,json,md,mdx,astro}' && eslint --max-warnings=0 --fix .",
11+
"lint": "prettier --check '**/*.{js,mjs,ts,tsx,json,md,mdx,astro}' && eslint --max-warnings=0 ."
1012
},
1113
"dependencies": {
1214
"@astrojs/starlight": "^0.36.2",
@@ -17,5 +19,17 @@
1719
"sharp": "^0.34.5",
1820
"starlight-fullview-mode": "^0.2.6",
1921
"starlight-links-validator": "^0.19.1"
22+
},
23+
"devDependencies": {
24+
"@eslint/js": "^9.39.1",
25+
"@typescript-eslint/parser": "^8.48.0",
26+
"astro-eslint-parser": "^1.2.2",
27+
"eslint": "^9.39.1",
28+
"eslint-config-prettier": "^10.1.8",
29+
"eslint-plugin-astro": "^1.5.0",
30+
"globals": "^16.5.0",
31+
"prettier": "3.6.2",
32+
"prettier-plugin-astro": "0.14.1",
33+
"typescript-eslint": "^8.48.0"
2034
}
2135
}

0 commit comments

Comments
 (0)