build: migrate linter & formatter to Biome

This commit is contained in:
Asuka109 2025-03-18 00:44:16 +08:00
parent 1c0fc92515
commit 371b48fdfd
14 changed files with 95 additions and 144 deletions

View file

@ -1,15 +0,0 @@
.DS_Store
node_modules
build
.svelte-kit
package
main.js
.env
.env.*
!.env.example
dist
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock

View file

@ -1,37 +0,0 @@
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'plugin:prettier/recommended'
],
rules: {
'prettier/prettier': 'error',
// Just annoying
'@typescript-eslint/no-explicit-any': ['off'],
'@typescript-eslint/no-unused-vars': ['off'],
'@typescript-eslint/ban-ts-comment': ['off']
},
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
extraFileExtensions: ['.svelte']
},
env: {
browser: true,
es2017: true,
node: true
},
overrides: [
{
files: ['*.svelte'],
parser: 'svelte-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser'
}
}
]
};

View file

@ -1,23 +0,0 @@
.DS_Store
node_modules
build
bin
.svelte-kit
.sveltepress
package
main.js
.env
.env.*
!.env.example
.vscode-test
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
dist
markdown
temp
web/static/docs/harperjs/ref
manifest.json

View file

@ -1,16 +0,0 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"endOfLine": "auto",
"plugins": ["prettier-plugin-svelte"],
"overrides": [
{
"files": "*.svelte",
"options": {
"parser": "svelte"
}
}
]
}

View file

@ -1,5 +1,3 @@
{
"recommendations": [
"elijah-potter.harper"
]
}
"recommendations": ["elijah-potter.harper", "biomejs.biome"]
}

70
biome.json Normal file
View file

@ -0,0 +1,70 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": true,
"include": ["packages/**/*", "**/*.json"],
"ignore": [
"node_modules",
"dist",
"target",
"build",
"*.zip",
"**/*.rs",
".vscode-test",
".svelte-kit",
"pnpm-lock.yaml",
"package-lock.json",
"yarn.lock"
]
},
"formatter": {
"enabled": true,
"lineWidth": 100,
"indentStyle": "tab",
"useEditorconfig": true
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"a11y": {
"noSvgWithoutTitle": "off"
},
"style": {
"noNonNullAssertion": "off",
"noUselessElse": "off"
},
"complexity": {
"noForEach": "off",
"noStaticOnlyClass": "off",
"noThisInStatic": "off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single"
}
},
"overrides": [
{
"include": ["*.svelte", "*.astro", "*.vue"],
"linter": {
"rules": {
"style": {
"useConst": "off",
"useImportType": "off"
}
}
}
}
]
}

View file

@ -1,7 +1,7 @@
# Format entire project
format:
cargo fmt
cd "{{justfile_directory()}}/packages"; pnpm prettier -w .
cd "{{justfile_directory()}}/packages"; pnpm check --write .
# Build the WebAssembly for a specific target (usually either `web` or `bundler`)
build-wasm:
@ -172,7 +172,7 @@ update-vscode-linters:
'.contributes.configuration.properties += $linters' <<< \
"$manifest_without_linters" > \
package.json
pnpm prettier --write package.json
pnpm biome --write package.json
# Run Rust formatting and linting.
check-rust:
@ -189,8 +189,7 @@ check: check-rust build-web
cd "{{justfile_directory()}}/packages"
pnpm install
pnpm prettier --check .
pnpm eslint .
pnpm biome check .
# Needed because Svelte has special linters
cd web

View file

@ -1,20 +1,14 @@
{
"private": true,
"scripts": {
"check-dependency-version-consistency": "check-dependency-version-consistency"
},
"devDependencies": {
"@babel/runtime": "catalog:",
"@typescript-eslint/eslint-plugin": "catalog:",
"@typescript-eslint/parser": "catalog:",
"check-dependency-version-consistency": "^5.0.0",
"eslint": "catalog:",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-svelte": "^2.46.1",
"prettier": "catalog:",
"prettier-plugin-svelte": "^3.0.3",
"typescript": "catalog:"
},
"packageManager": "pnpm@10.6.3"
"private": true,
"scripts": {
"check-dependency-version-consistency": "check-dependency-version-consistency",
"check": "biome check --write ."
},
"devDependencies": {
"@babel/runtime": "catalog:",
"@biomejs/biome": "1.9.4",
"check-dependency-version-consistency": "^5.0.0",
"typescript": "catalog:"
},
"packageManager": "pnpm@10.6.3"
}

View file

@ -31,6 +31,7 @@
},
"dependencies": {
"crelt": "^1.0.5",
"tslib": "catalog:",
"harper.js": "workspace:*",
"lodash-es": "^4.17.21"
}

View file

@ -1,5 +1,5 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": ["dbaeumer.vscode-eslint", "connor4312.esbuild-problem-matchers"]
"recommendations": ["connor4312.esbuild-problem-matchers"]
}

View file

@ -22,14 +22,8 @@
"engines": {
"vscode": "^1.89.0"
},
"categories": [
"Other"
],
"keywords": [
"grammar",
"spellcheck",
"writing"
],
"categories": ["Other"],
"keywords": ["grammar", "spellcheck", "writing"],
"activationEvents": [
"onLanguage:c",
"onLanguage:cmake",
@ -86,12 +80,7 @@
"harper.diagnosticSeverity": {
"scope": "resource",
"type": "string",
"enum": [
"error",
"hint",
"information",
"warning"
],
"enum": ["error", "hint", "information", "warning"],
"default": "information",
"description": "How severe do you want diagnostics to appear in the editor?"
},
@ -1525,18 +1514,15 @@
"test": "node build/tests/runTests.js",
"vscode:prepublish": "pnpm lint && tsc --noEmit && node esbuild.cjs --production",
"package": "vsce package",
"lint": "eslint src --ext ts"
"lint": "biome check src/**/*.ts"
},
"devDependencies": {
"@types/jasmine": "^5.1.7",
"@types/node": "catalog:",
"@types/vscode": "^1.89.0",
"@typescript-eslint/eslint-plugin": "catalog:",
"@typescript-eslint/parser": "catalog:",
"@vscode/test-electron": "^2.3.9",
"@vscode/vsce": "^3.0.0",
"esbuild": "^0.25.0",
"eslint": "catalog:",
"jasmine": "^5.6.0",
"typescript": "catalog:"
},

View file

@ -22,7 +22,7 @@
"svelte": "^5.15.0",
"svelte-check": "^4.1.5",
"tailwindcss": "^3.3.3",
"tslib": "^2.4.1",
"tslib": "catalog:",
"vite": "^6.1.0",
"typescript": "catalog:",
"vite-plugin-pwa": "^0.21.1",

View file

@ -11,11 +11,8 @@
"start": "wp-scripts start --webpack-copy-php"
},
"devDependencies": {
"@wordpress/eslint-plugin": "^22.2.0",
"@wordpress/scripts": "^30.9.0",
"@wp-now/wp-now": "^0.1.74",
"eslint": "catalog:",
"prettier": "catalog:",
"typescript": "catalog:"
},
"dependencies": {

View file

@ -4,10 +4,7 @@ packages:
- packages/harper.js/examples/*
catalog:
'@typescript-eslint/eslint-plugin': ^8.18.1
'@typescript-eslint/parser': ^8.18.1
eslint: ^8.57.0
prettier: ^3.5.3
typescript: ^5.8.2
tslib: ^2.8.1
'@types/node': ^22.13.10
'@babel/runtime': ^7.26.10