Skip to content

Commit

Permalink
Add code linting and formatting (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
karniv00l authored Sep 14, 2023
1 parent 8ffcbfa commit af720ef
Show file tree
Hide file tree
Showing 17 changed files with 224 additions and 54 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
// NOTE: keep this in sync with: .vscode/extensions.json
"extensions": [
"davidanson.vscode-markdownlint",
"streetsidesoftware.code-spell-checker"
"streetsidesoftware.code-spell-checker",
"biomejs.biome"
]
}
},
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ concurrency:

on:
pull_request:
branches: [ master ]
branches: [master]

jobs:
validate:
Expand All @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
node-version-file: ".nvmrc"
cache: "npm"
- run: npm ci
- run: npm run build
5 changes: 2 additions & 3 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ jobs:
const fs = require('fs');
fs.writeFileSync('${{github.workspace}}/build.zip', Buffer.from(download.data));
- run: unzip build.zip -d build

- name: Deploy preview to Cloudflare Pages
id: deploy
uses: cloudflare/pages-action@v1
Expand All @@ -50,9 +49,9 @@ jobs:
projectName: wiki
directory: build
gitHubToken: ${{ secrets.GITHUB_TOKEN }} # GitHub Deployments
wranglerVersion: '3'
wranglerVersion: "3"

- name: 'Comment on PR'
- name: "Comment on PR"
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ concurrency:

on:
push:
branches: [ master ]
branches: [master]

env:
PRINCE_VER: 15.1
Expand All @@ -25,8 +25,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
node-version-file: ".nvmrc"
cache: "npm"

- name: Install PrinceXML
run: |
Expand Down Expand Up @@ -65,4 +65,4 @@ jobs:
directory: build
gitHubToken: ${{ secrets.GITHUB_TOKEN }} # GitHub Deployments
branch: master
wranglerVersion: '3'
wranglerVersion: "3"
18 changes: 9 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ concurrency:

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:
typescript:
code:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
node-version-file: ".nvmrc"
cache: "npm"
- run: npm ci
- run: npm run lint:ts

Expand All @@ -36,8 +36,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
node-version-file: ".nvmrc"
cache: "npm"
- run: npm ci
- run: npm run lint:links

Expand All @@ -48,7 +48,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
node-version-file: ".nvmrc"
cache: "npm"
- run: npm ci
- run: npm run lint:md
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// NOTE: keep this in sync with: .devcontainer/devcontainer.json
"recommendations": [
"davidanson.vscode-markdownlint",
"streetsidesoftware.code-spell-checker"
"streetsidesoftware.code-spell-checker",
"biomejs.biome"
]
}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
{
"typescript.tsdk": "./node_modules/typescript/lib",
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"editor.formatOnSave": true,
"cSpell.words": [
"Airmass",
"autotune",
"autotuner",
"biomejs",
"bootloader",
"CANBUS",
"Colour",
Expand All @@ -11,6 +20,7 @@
"Deadtime",
"deadzone",
"debugmode",
"devcontainer",
"devcontainers",
"DFCO",
"dyno",
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Docusaurus guides: [https://docusaurus.io/docs/category/guides](https://docusaur

```bash
npm run lint

npm run lint:fix
```

### Build
Expand Down
44 changes: 44 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"$schema": "https://biomejs.dev/schemas/1.1.2/schema.json",
"organizeImports": {
"enabled": true
},
"files": {
"ignore": [".devcontainer", ".vscode", "node_modules", ".docusaurus", "build", "pdf"]
},
"linter": {
"enabled": true,
"rules": {
"all": true,
"style": {
"all": true,
"useEnumInitializers": "off",
"noNonNullAssertion": "off"
},
"suspicious": {
"all": true,
"noConsoleLog": "off"
},
"nursery": {
"all": true,
"useExhaustiveDependencies": "off"
},
"complexity": {
"all": true,
"noForEach": "off"
}
}
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"lineWidth": 100,
"indentSize": 2
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"trailingComma": "all"
}
}
}
12 changes: 6 additions & 6 deletions docs/02-Intro-Start-Here/_category_.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"label": "Intro - Start Here",
"link": {
"type": "generated-index",
"description": "Where to start learning about FOME."
}
}
"label": "Intro - Start Here",
"link": {
"type": "generated-index",
"description": "Where to start learning about FOME."
}
}
12 changes: 6 additions & 6 deletions docs/03-Fundamentals-Of-Tuning/_category_.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"label": "Fundamentals of FOME tuning",
"link": {
"type": "generated-index",
"description": "The place to learn how to start tuning your FOME Hardware"
}
}
"label": "Fundamentals of FOME tuning",
"link": {
"type": "generated-index",
"description": "The place to learn how to start tuning your FOME Hardware"
}
}
2 changes: 1 addition & 1 deletion docs/04-Sensors-And-Gauges/_category_.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"type": "generated-index",
"description": "Information on all sensor inputs and data outputs"
}
}
}
19 changes: 6 additions & 13 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@ const pdfName = 'wiki.fome.pdf';
const pdfChecksum = () => {
const data = fs.readFileSync(`static/pdf/${pdfName}`, 'utf8');

return crypto
.createHash('md5')
.update(data, 'utf8')
.digest('hex');
}
return crypto.createHash('md5').update(data, 'utf8').digest('hex');
};

const pdfUrl = `${isBuild ? url : 'http://localhost:3000'}/pdf/${pdfName}?v=${pdfChecksum()}`;

Expand Down Expand Up @@ -60,12 +57,9 @@ const config = {
routeBasePath: '/', // Serve the docs at the site's root
sidebarPath: require.resolve('./sidebars.js'),
// Remove this to remove the "edit this page" links.
editUrl:
'https://github.com/FOME-Tech/wiki/tree/master',
editUrl: 'https://github.com/FOME-Tech/wiki/tree/master',
remarkPlugins: [require('remark-math')],
rehypePlugins: [
[require('rehype-katex'), { output: 'mathml' }]
],
rehypePlugins: [[require('rehype-katex'), { output: 'mathml' }]],
},
blog: false,
theme: {
Expand All @@ -79,8 +73,7 @@ const config = {
{
href: 'https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css',
type: 'text/css',
integrity:
'sha384-odtC+0UGzzFL/6PNoE8rX/SPcQDXBJ+uRepguP4QkPCm2LBxH3FA3y+fKSiJ+AmM',
integrity: 'sha384-odtC+0UGzzFL/6PNoE8rX/SPcQDXBJ+uRepguP4QkPCm2LBxH3FA3y+fKSiJ+AmM',
crossorigin: 'anonymous',
},
],
Expand Down Expand Up @@ -157,7 +150,7 @@ const config = {
style: {
height: 30,
marginTop: -2,
}
},
},
items: [
{
Expand Down
Loading

0 comments on commit af720ef

Please sign in to comment.