mirror of https://github.com/FOME-Tech/wiki.git
Add code linting and formatting (#154)
This commit is contained in:
parent
8ffcbfa230
commit
af720ef597
|
@ -20,7 +20,8 @@
|
||||||
// NOTE: keep this in sync with: .vscode/extensions.json
|
// NOTE: keep this in sync with: .vscode/extensions.json
|
||||||
"extensions": [
|
"extensions": [
|
||||||
"davidanson.vscode-markdownlint",
|
"davidanson.vscode-markdownlint",
|
||||||
"streetsidesoftware.code-spell-checker"
|
"streetsidesoftware.code-spell-checker",
|
||||||
|
"biomejs.biome"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,7 +17,7 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.nvmrc'
|
node-version-file: ".nvmrc"
|
||||||
cache: 'npm'
|
cache: "npm"
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
|
|
|
@ -40,7 +40,6 @@ jobs:
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
fs.writeFileSync('${{github.workspace}}/build.zip', Buffer.from(download.data));
|
fs.writeFileSync('${{github.workspace}}/build.zip', Buffer.from(download.data));
|
||||||
- run: unzip build.zip -d build
|
- run: unzip build.zip -d build
|
||||||
|
|
||||||
- name: Deploy preview to Cloudflare Pages
|
- name: Deploy preview to Cloudflare Pages
|
||||||
id: deploy
|
id: deploy
|
||||||
uses: cloudflare/pages-action@v1
|
uses: cloudflare/pages-action@v1
|
||||||
|
@ -50,9 +49,9 @@ jobs:
|
||||||
projectName: wiki
|
projectName: wiki
|
||||||
directory: build
|
directory: build
|
||||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }} # GitHub Deployments
|
gitHubToken: ${{ secrets.GITHUB_TOKEN }} # GitHub Deployments
|
||||||
wranglerVersion: '3'
|
wranglerVersion: "3"
|
||||||
|
|
||||||
- name: 'Comment on PR'
|
- name: "Comment on PR"
|
||||||
uses: actions/github-script@v3
|
uses: actions/github-script@v3
|
||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
|
@ -25,8 +25,8 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.nvmrc'
|
node-version-file: ".nvmrc"
|
||||||
cache: 'npm'
|
cache: "npm"
|
||||||
|
|
||||||
- name: Install PrinceXML
|
- name: Install PrinceXML
|
||||||
run: |
|
run: |
|
||||||
|
@ -65,4 +65,4 @@ jobs:
|
||||||
directory: build
|
directory: build
|
||||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }} # GitHub Deployments
|
gitHubToken: ${{ secrets.GITHUB_TOKEN }} # GitHub Deployments
|
||||||
branch: master
|
branch: master
|
||||||
wranglerVersion: '3'
|
wranglerVersion: "3"
|
||||||
|
|
|
@ -17,15 +17,15 @@ on:
|
||||||
branches: [master]
|
branches: [master]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
typescript:
|
code:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.nvmrc'
|
node-version-file: ".nvmrc"
|
||||||
cache: 'npm'
|
cache: "npm"
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run lint:ts
|
- run: npm run lint:ts
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.nvmrc'
|
node-version-file: ".nvmrc"
|
||||||
cache: 'npm'
|
cache: "npm"
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run lint:links
|
- run: npm run lint:links
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.nvmrc'
|
node-version-file: ".nvmrc"
|
||||||
cache: 'npm'
|
cache: "npm"
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run lint:md
|
- run: npm run lint:md
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// NOTE: keep this in sync with: .devcontainer/devcontainer.json
|
// NOTE: keep this in sync with: .devcontainer/devcontainer.json
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"davidanson.vscode-markdownlint",
|
"davidanson.vscode-markdownlint",
|
||||||
"streetsidesoftware.code-spell-checker"
|
"streetsidesoftware.code-spell-checker",
|
||||||
|
"biomejs.biome"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -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": [
|
"cSpell.words": [
|
||||||
"Airmass",
|
"Airmass",
|
||||||
"autotune",
|
"autotune",
|
||||||
"autotuner",
|
"autotuner",
|
||||||
|
"biomejs",
|
||||||
"bootloader",
|
"bootloader",
|
||||||
"CANBUS",
|
"CANBUS",
|
||||||
"Colour",
|
"Colour",
|
||||||
|
@ -11,6 +20,7 @@
|
||||||
"Deadtime",
|
"Deadtime",
|
||||||
"deadzone",
|
"deadzone",
|
||||||
"debugmode",
|
"debugmode",
|
||||||
|
"devcontainer",
|
||||||
"devcontainers",
|
"devcontainers",
|
||||||
"DFCO",
|
"DFCO",
|
||||||
"dyno",
|
"dyno",
|
||||||
|
|
|
@ -30,6 +30,8 @@ Docusaurus guides: [https://docusaurus.io/docs/category/guides](https://docusaur
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run lint
|
npm run lint
|
||||||
|
|
||||||
|
npm run lint:fix
|
||||||
```
|
```
|
||||||
|
|
||||||
### Build
|
### Build
|
||||||
|
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,11 +13,8 @@ const pdfName = 'wiki.fome.pdf';
|
||||||
const pdfChecksum = () => {
|
const pdfChecksum = () => {
|
||||||
const data = fs.readFileSync(`static/pdf/${pdfName}`, 'utf8');
|
const data = fs.readFileSync(`static/pdf/${pdfName}`, 'utf8');
|
||||||
|
|
||||||
return crypto
|
return crypto.createHash('md5').update(data, 'utf8').digest('hex');
|
||||||
.createHash('md5')
|
};
|
||||||
.update(data, 'utf8')
|
|
||||||
.digest('hex');
|
|
||||||
}
|
|
||||||
|
|
||||||
const pdfUrl = `${isBuild ? url : 'http://localhost:3000'}/pdf/${pdfName}?v=${pdfChecksum()}`;
|
const pdfUrl = `${isBuild ? url : 'http://localhost:3000'}/pdf/${pdfName}?v=${pdfChecksum()}`;
|
||||||
|
|
||||||
|
@ -60,12 +57,9 @@ const config = {
|
||||||
routeBasePath: '/', // Serve the docs at the site's root
|
routeBasePath: '/', // Serve the docs at the site's root
|
||||||
sidebarPath: require.resolve('./sidebars.js'),
|
sidebarPath: require.resolve('./sidebars.js'),
|
||||||
// Remove this to remove the "edit this page" links.
|
// Remove this to remove the "edit this page" links.
|
||||||
editUrl:
|
editUrl: 'https://github.com/FOME-Tech/wiki/tree/master',
|
||||||
'https://github.com/FOME-Tech/wiki/tree/master',
|
|
||||||
remarkPlugins: [require('remark-math')],
|
remarkPlugins: [require('remark-math')],
|
||||||
rehypePlugins: [
|
rehypePlugins: [[require('rehype-katex'), { output: 'mathml' }]],
|
||||||
[require('rehype-katex'), { output: 'mathml' }]
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
blog: false,
|
blog: false,
|
||||||
theme: {
|
theme: {
|
||||||
|
@ -79,8 +73,7 @@ const config = {
|
||||||
{
|
{
|
||||||
href: 'https://cdn.jsdelivr.net/npm/katex@0.13.24/dist/katex.min.css',
|
href: 'https://cdn.jsdelivr.net/npm/katex@0.13.24/dist/katex.min.css',
|
||||||
type: 'text/css',
|
type: 'text/css',
|
||||||
integrity:
|
integrity: 'sha384-odtC+0UGzzFL/6PNoE8rX/SPcQDXBJ+uRepguP4QkPCm2LBxH3FA3y+fKSiJ+AmM',
|
||||||
'sha384-odtC+0UGzzFL/6PNoE8rX/SPcQDXBJ+uRepguP4QkPCm2LBxH3FA3y+fKSiJ+AmM',
|
|
||||||
crossorigin: 'anonymous',
|
crossorigin: 'anonymous',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -157,7 +150,7 @@ const config = {
|
||||||
style: {
|
style: {
|
||||||
height: 30,
|
height: 30,
|
||||||
marginTop: -2,
|
marginTop: -2,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
"remark-math": "^3.0.1"
|
"remark-math": "^3.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@biomejs/biome": "1.1.2",
|
||||||
"@docusaurus/module-type-aliases": "^2.4.1",
|
"@docusaurus/module-type-aliases": "^2.4.1",
|
||||||
"@tsconfig/docusaurus": "^2.0.0",
|
"@tsconfig/docusaurus": "^2.0.0",
|
||||||
"docusaurus-prince-pdf": "^1.2.1",
|
"docusaurus-prince-pdf": "^1.2.1",
|
||||||
|
@ -2068,6 +2069,123 @@
|
||||||
"node": ">=6.9.0"
|
"node": ">=6.9.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@biomejs/biome": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.1.2.tgz",
|
||||||
|
"integrity": "sha512-JEVWchqo0Xhl86IJgOh0xESWnNRUXBUDByCBR8TA4lIPzm/6U6Tv77+MblNkZ8MvwCtP6PlBNGdQcGKKabtuHA==",
|
||||||
|
"dev": true,
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"bin": {
|
||||||
|
"biome": "bin/biome"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.*"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@biomejs/cli-darwin-arm64": "1.1.2",
|
||||||
|
"@biomejs/cli-darwin-x64": "1.1.2",
|
||||||
|
"@biomejs/cli-linux-arm64": "1.1.2",
|
||||||
|
"@biomejs/cli-linux-x64": "1.1.2",
|
||||||
|
"@biomejs/cli-win32-arm64": "1.1.2",
|
||||||
|
"@biomejs/cli-win32-x64": "1.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@biomejs/cli-darwin-arm64": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.1.2.tgz",
|
||||||
|
"integrity": "sha512-YyqWeNZchPxlvxtdo2vMBkzrwllaNS3+DZ6j01mUCVIZE9kAzF/edMV2O38L2AEtnRLU1TI1f71Jai3ThILClg==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@biomejs/cli-darwin-x64": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.1.2.tgz",
|
||||||
|
"integrity": "sha512-Sofxcu50AHJyQS6Xx3OF2egQQ7Un5YFVF5/umNFa+kSNrrCu/ucmzrk8FcGS2dOSs4L2LqD6ZDWjvbcikjzLYQ==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@biomejs/cli-linux-arm64": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.1.2.tgz",
|
||||||
|
"integrity": "sha512-wtaQgpoVMZEKf1GlDlFGAJP1j6gnh4L4kJN8PQPOBAdKIUZ/YSjqVp0z28vli5xCQ57xCn1gH4Xoqw2gVYu1tQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@biomejs/cli-linux-x64": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.1.2.tgz",
|
||||||
|
"integrity": "sha512-TYIUjCXbY+kxnJgv8GESplMagB1GdOcMV21JGRATqnhUI4BvG6sjs3gfi+sdjLBQdbHhsISXW3yfUlv07HKqhg==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@biomejs/cli-win32-arm64": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.1.2.tgz",
|
||||||
|
"integrity": "sha512-yApn85KuJ+Ty5zxbqWnaifX4ONtZG+snu12RNKi8fxSVVCXzQ/k2PfsWQbsyvCG05qshSvNKtM54cuf+vhUIsw==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@biomejs/cli-win32-x64": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.1.2.tgz",
|
||||||
|
"integrity": "sha512-qebNvIrFj2TJ+K0JVGo1HkgV2y5jis6aOZDC1SWuk53GnqjSLdR+p1v86ZByOjYr1v+tjc67EXmEepk06VVvpA==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@colors/colors": {
|
"node_modules/@colors/colors": {
|
||||||
"version": "1.5.0",
|
"version": "1.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz",
|
||||||
|
|
|
@ -6,7 +6,10 @@
|
||||||
"docusaurus": "docusaurus",
|
"docusaurus": "docusaurus",
|
||||||
"start": "docusaurus start --host 0.0.0.0",
|
"start": "docusaurus start --host 0.0.0.0",
|
||||||
"build": "docusaurus build",
|
"build": "docusaurus build",
|
||||||
"lint": "npm run lint:ts && npm run lint:links && npm run lint:md",
|
"lint": "npm run lint:biome && npm run lint:ts && npm run lint:links && npm run lint:md",
|
||||||
|
"lint:biome": "biome check .",
|
||||||
|
"lint:fix": "biome format --write . && biome check --apply .",
|
||||||
|
"lint:fix:unsafe": "biome check . --apply-unsafe .",
|
||||||
"lint:ts": "tsc",
|
"lint:ts": "tsc",
|
||||||
"lint:links": "node scripts/linkValidator.js",
|
"lint:links": "node scripts/linkValidator.js",
|
||||||
"lint:md": "npx markdownlint-cli docs",
|
"lint:md": "npx markdownlint-cli docs",
|
||||||
|
@ -32,6 +35,7 @@
|
||||||
"remark-math": "^3.0.1"
|
"remark-math": "^3.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@biomejs/biome": "1.1.2",
|
||||||
"@docusaurus/module-type-aliases": "^2.4.1",
|
"@docusaurus/module-type-aliases": "^2.4.1",
|
||||||
"@tsconfig/docusaurus": "^2.0.0",
|
"@tsconfig/docusaurus": "^2.0.0",
|
||||||
"docusaurus-prince-pdf": "^1.2.1",
|
"docusaurus-prince-pdf": "^1.2.1",
|
||||||
|
|
|
@ -34,14 +34,12 @@ const validateAbsoluteUrls = (files) => {
|
||||||
console.log('❌ Failed\n');
|
console.log('❌ Failed\n');
|
||||||
console.log(red(`Absolute URLs to "${wikiUrl}" found in the following files:\n`));
|
console.log(red(`Absolute URLs to "${wikiUrl}" found in the following files:\n`));
|
||||||
errors.forEach((error) => {
|
errors.forEach((error) => {
|
||||||
console.log(
|
console.log(`[${error.fileName}:${error.lineNo}] ${error.lineContent.trim()}`);
|
||||||
`[${error.fileName}:${error.lineNo}] ${error.lineContent.trim()}`
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load all md and mdx files from / docs and process them
|
* Load all md and mdx files from / docs and process them
|
||||||
|
@ -54,6 +52,6 @@ const main = () => {
|
||||||
// validateRelativeUrls(files);
|
// validateRelativeUrls(files);
|
||||||
|
|
||||||
console.log('✅ Ok');
|
console.log('✅ Ok');
|
||||||
}
|
};
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
|
Loading…
Reference in New Issue