Skip to content

Commit

Permalink
use biome
Browse files Browse the repository at this point in the history
  • Loading branch information
u1-liquid committed Nov 24, 2024
1 parent b4865fd commit 00d041e
Show file tree
Hide file tree
Showing 71 changed files with 1,142 additions and 2,217 deletions.
41 changes: 17 additions & 24 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
{
"name": "Misskey",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspace",
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "20"
},
"ghcr.io/devcontainers-contrib/features/corepack:1": {}
},
"forwardPorts": [3000],
"postCreateCommand": "sudo chmod 755 .devcontainer/init.sh && .devcontainer/init.sh",
"customizations": {
"vscode": {
"extensions": [
"editorconfig.editorconfig",
"dbaeumer.vscode-eslint",
"Vue.volar",
"Orta.vscode-jest",
"dbaeumer.vscode-eslint",
"mrmlnc.vscode-json5"
]
}
}
"name": "Misskey",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspace",
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "20"
},
"ghcr.io/devcontainers-contrib/features/corepack:1": {}
},
"forwardPorts": [3000],
"postCreateCommand": "sudo chmod 755 .devcontainer/init.sh && .devcontainer/init.sh",
"customizations": {
"vscode": {
"extensions": ["biomejs.biome", "editorconfig.editorconfig", "Vue.volar", "Orta.vscode-jest", "mrmlnc.vscode-json5"]
}
}
}
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
[*.{json,yml,yaml}]
indent_style = space
4 changes: 1 addition & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ on:
- packages/frontend/**
- packages/sw/**
- packages/misskey-js/**
- packages/shared/.eslintrc.js
pull_request:
paths:
- packages/backend/**
- packages/frontend/**
- packages/sw/**
- packages/misskey-js/**
- packages/shared/.eslintrc.js

jobs:
pnpm_install:
Expand Down Expand Up @@ -63,7 +61,7 @@ jobs:
cache: 'pnpm'
- run: corepack enable
- run: pnpm i --frozen-lockfile
- run: pnpm --filter ${{ matrix.workspace }} run eslint
- run: pnpm --filter ${{ matrix.workspace }} run biome ci --reporter=github --max-diagnostics=none

typecheck:
needs: [pnpm_install]
Expand Down
8 changes: 1 addition & 7 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{
"recommendations": [
"editorconfig.editorconfig",
"dbaeumer.vscode-eslint",
"Vue.volar",
"Orta.vscode-jest",
"mrmlnc.vscode-json5"
]
"recommendations": ["biomejs.biome", "editorconfig.editorconfig", "Vue.volar", "Orta.vscode-jest", "mrmlnc.vscode-json5"]
}
154 changes: 154 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
"files": {
"ignore": [
"*.min.js",
"api.json",
"built",
"nsfw-model",
"packages/backend/built",
"packages/backend/nsfw-model",
"packages/frontend/built",
"packages/sw/built",
"packages/misskey-js/built",
"packages/misskey-reversi/built",
"packages/misskey-bubble-game/built",
"locales/index.d.ts",
"packages/misskey-js/generator/api.json"
]
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"ignore": ["packages/misskey-js/src/autogen"],
"rules": {
"recommended": true,
"complexity": {
"noForEach": "info",
"noUselessConstructor": {
"level": "info",
"fix": "none"
},
"noUselessLabel": {
"level": "info",
"fix": "none"
},
"noUselessUndefinedInitialization": {
"level": "info",
"fix": "none"
},
"useArrowFunction": {
"level": "info",
"fix": "none"
},
"useLiteralKeys": {
"level": "info",
"fix": "none"
},
"useOptionalChain": {
"level": "info",
"fix": "none"
}
},
"performance": {
"noDelete": {
"level": "info",
"fix": "none"
}
},
"style": {
"noCommaOperator": "warn",
"noNegationElse": {
"level": "off",
"fix": "none"
},
"noNonNullAssertion": {
"level": "info",
"fix": "none"
},
"noParameterAssign": "info",
"noUselessElse": {
"level": "info",
"fix": "none"
},
"useImportType": {
"level": "off",
"fix": "none"
},
"useNodejsImportProtocol": {
"level": "off",
"fix": "none"
},
"useTemplate": {
"level": "warn",
"fix": "safe"
}
},
"suspicious": {
"noAssignInExpressions": "info",
"noConfusingVoidType": {
"level": "warn",
"fix": "none"
},
"noDoubleEquals": {
"level": "warn",
"fix": "none",
"options": {
"ignoreNull": false
}
},
"noExplicitAny": "warn",
"noImplicitAnyLet": "warn"
}
}
},
"formatter": {
"enabled": true,
"lineWidth": 140,
"useEditorconfig": true
},
"javascript": {
"formatter": {
"arrowParentheses": "asNeeded",
"quoteStyle": "single"
},
"parser": {
"unsafeParameterDecoratorsEnabled": true
}
},
"overrides": [
{
"include": ["packages/backend/migration/*.js", "migration/*.js"],
"linter": {
"rules": {
"style": {
"noUnusedTemplateLiteral": {
"level": "off",
"fix": "none"
}
}
}
}
},
{
"include": ["*.vue"],
"linter": {
"rules": {
"style": {
"useConst": {
"level": "off",
"fix": "none"
},
"useImportType": {
"level": "off",
"fix": "none"
}
}
}
}
}
]
}
15 changes: 15 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Refer for explanation to following link:
# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md

pre-push:
commands:
check:
glob: "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc,pug,vue}"
run: pnpm dlx @biomejs/biome check --no-errors-on-unmatched --files-ignore-unknown=true --colors=off --diagnostic-level=error {push_files}

pre-commit:
commands:
check:
glob: "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc,pug,vue}"
run: pnpm dlx @biomejs/biome check --write --no-errors-on-unmatched --files-ignore-unknown=true --colors=off --diagnostic-level=error {staged_files}
stage_fixed: true
17 changes: 10 additions & 7 deletions locales/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
import * as fs from 'node:fs';
import * as yaml from 'js-yaml';

const merge = (...args) => args.reduce((a, c) => ({
...a,
...c,
...Object.entries(a)
.filter(([k]) => c && typeof c[k] === 'object')
.reduce((a, [k, v]) => (a[k] = merge(v, c[k]), a), {})
}), {});
const merge = (...args) => args.reduce((a, c) => {
for (const [k, v] of Object.entries(c)) {
if (typeof v === 'object' && typeof a[k] === 'object') {
a[k] = merge(a[k], v);
} else {
a[k] = v;
}
}
return a;
}, {});

const languages = [
'ar-SA',
Expand Down
Loading

0 comments on commit 00d041e

Please sign in to comment.