Skip to content

Commit

Permalink
Switch to biome (#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep authored Jul 29, 2024
1 parent 1c43980 commit 7bf9d9d
Show file tree
Hide file tree
Showing 38 changed files with 570 additions and 2,479 deletions.
68 changes: 0 additions & 68 deletions .eslintrc.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,3 @@ updates:
mui:
patterns:
- '@mui/*'
ts-eslint:
patterns:
- '@typescript-eslint/*'
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn run lint-staged
10 changes: 0 additions & 10 deletions .prettierignore

This file was deleted.

11 changes: 0 additions & 11 deletions .prettierrc.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"recommendations": ["arcanis.vscode-zipfs", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode"],
"recommendations": ["arcanis.vscode-zipfs", "biomejs.biome"],
}
10 changes: 3 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "always",
"[json][jsonc][typescript][typescriptreact]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "biomejs.biome",
},
"eslint.validate": ["typescript", "typescriptreact"],
"prettier.prettierPath": ".yarn/sdks/prettier/index.cjs",
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true,
},
"eslint.nodePath": ".yarn/sdks",
"typescript.enablePromptUseWorkspaceTsdk": true,
"[caddyfile]": {
"editor.defaultFormatter": "matthewpi.caddyfile-support",
Expand Down
20 changes: 0 additions & 20 deletions .yarn/sdks/prettier/bin/prettier.cjs

This file was deleted.

20 changes: 0 additions & 20 deletions .yarn/sdks/prettier/index.cjs

This file was deleted.

7 changes: 0 additions & 7 deletions .yarn/sdks/prettier/package.json

This file was deleted.

6 changes: 6 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ compressionLevel: mixed
enableGlobalCache: true

yarnPath: .yarn/releases/yarn-4.1.1.cjs

packageExtensions:
"react-plotly.js@*":
peerDependenciesMeta:
plotly.js:
optional: true
45 changes: 45 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true,
},
"javascript": {
"formatter": {
"semicolons": "asNeeded",
"quoteStyle": "single",
},
},
"linter": {
"rules": {
"complexity": {
"useLiteralKeys": "off", // conflicts with tsconfig noPropertyAccessFromIndexSignature: https://github.com/biomejs/biome/issues/463
},
},
},
"overrides": [
{
"include": [".vscode/*.json", "tsconfig.json", "**/*.jsonc"],
"json": {
"formatter": {
"trailingCommas": "all",
},
"parser": {
"allowComments": true,
"allowTrailingCommas": true,
},
},
},
{
"include": ["src/build-tools/rst.tsx", "src/build-tools/md.tsx"],
"linter": {
"rules": {
"correctness": {
"useJsxKeyInIterable": "off", // Static tree, no need for key
},
},
},
},
],
}
32 changes: 8 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@
"build": "tsc && vite build",
"preview": "vite preview",
"bundlesize": "tsc && vite-bundle-visualizer",
"lint": "$npm_execpath run lint:format && $npm_execpath run lint:style && $npm_execpath run lint:deps",
"lint:format": "prettier --write '**/*'",
"lint:style": "eslint '{*.ts,src/**/*.ts*}'",
"lint": "$npm_execpath run lint:check && $npm_execpath run lint:deps",
"lint:check": "biome check --write .",
"lint:deps": "depcheck --ignores=unfonts.css,@fontsource/iosevka,@fontsource/iosevka-aile,@yarnpkg/sdks,@tsconfig/strictest,@total-typescript/ts-reset",
"deploy": "$npm_execpath run build && rsync --recursive --delete --archive --compress --progress dist/ [email protected]:/srv/http/phil.red",
"postinstall": "husky install"
"prepare": "husky"
},
"files": [
"dist"
],
"files": ["dist"],
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.13.0",
Expand Down Expand Up @@ -51,6 +48,7 @@
"typed-jsx": "^0.1.1"
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@total-typescript/ts-reset": "^0.5.1",
"@tsconfig/strictest": "^2.0.5",
"@types/estree": "^1.0.5",
Expand All @@ -63,28 +61,15 @@
"@types/react-dom": "^18.3.0",
"@types/react-is": "^18.3.0",
"@types/react-plotly.js": "^2.6.3",
"@typescript-eslint/eslint-plugin": "^7.17.0",
"@typescript-eslint/parser": "^7.17.0",
"@vitejs/plugin-react": "^4.3.1",
"@yarnpkg/sdks": "^3.1.2",
"depcheck": "^1.4.7",
"eslint": "^8.57.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-flying-sheep": "^5.2.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.9.0",
"eslint-plugin-no-foreach": "^1.0.0",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-prefer-function-component": "^3.3.0",
"estree-walker": "^3.0.3",
"globby": "^14.0.1",
"husky": ">=9",
"lint-staged": ">=15",
"husky": ">=9.1.3",
"lint-staged": ">=15.2.7",
"magic-string": "^0.30.10",
"markdown-it": "^14.1.0",
"prettier": "^3.3.2",
"react-json-tree": "^0.19.0",
"restructured": "^0.0.11",
"rollup": "^4.18.0",
Expand All @@ -95,7 +80,6 @@
},
"packageManager": "[email protected]",
"lint-staged": {
"!(rawPosts)": "prettier --write",
"*.ts{,x}": "eslint --cache --fix"
"!(rawPosts)": "biome check --no-errors-on-unmatched --files-ignore-unknown=true --write"
}
}
1 change: 0 additions & 1 deletion posts/2017-04-12-typescript-declarations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Now i can create module declaration files as ``typings/module-name.d.ts``, e.g.

.. code:: typescript
/* eslint import/no-extraneous-dependencies: 0 */
import { Plugin } from 'postcss'
declare namespace postcssModules {
Expand Down
2 changes: 1 addition & 1 deletion posts/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Document } from '../../markup'
import type { Document } from '../../markup'

interface Documents {
[key: string]: Document
Expand Down
32 changes: 24 additions & 8 deletions src/build-tools/md.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** @jsxImportSource ../markup */
/* eslint import/no-extraneous-dependencies: ['error', {devDependencies: true}] */

import MarkdownIt from 'markdown-it'
import Token from 'markdown-it/lib/token.mjs'
Expand Down Expand Up @@ -47,13 +46,20 @@ function convertNode(token: Token): m.Node[] {
case 'text':
return [token.content]
case 'paragraph':
return [<m.Paragraph pos={pos(token)}>{convertChildren(token)}</m.Paragraph>]
return [
<m.Paragraph pos={pos(token)}>{convertChildren(token)}</m.Paragraph>,
]
case 'heading': {
const level = /h(?<level>[1-6])/.exec(token.tag)?.groups?.['level']
if (!level) throw new ASTError(`Unexpected header tag ${token.tag}`, token)
if (!level)
throw new ASTError(`Unexpected header tag ${token.tag}`, token)
const anchor = undefined // TODO
return [
<m.Title level={parseInt(level, 10)} anchor={anchor} pos={pos(token)}>
<m.Title
level={Number.parseInt(level, 10)}
anchor={anchor}
pos={pos(token)}
>
{convertChildren(token)}
</m.Title>,
]
Expand All @@ -76,19 +82,29 @@ function convertNode(token: Token): m.Node[] {
case 'fence':
return [<m.CodeBlock pos={pos(token)}>{token.content}</m.CodeBlock>]
case 'bullet_list':
return [<m.BulletList pos={pos(token)}>{convertChildren(token)}</m.BulletList>]
return [
<m.BulletList pos={pos(token)}>{convertChildren(token)}</m.BulletList>,
]
case 'list_item':
return [<m.ListItem pos={pos(token)}>{convertChildren(token)}</m.ListItem>]
return [
<m.ListItem pos={pos(token)}>{convertChildren(token)}</m.ListItem>,
]
default:
throw new ASTError(`Unknown token type “${token.type}”`, JSON.stringify(token))
throw new ASTError(
`Unknown token type “${token.type}”`,
JSON.stringify(token),
)
}
}

function convertChildren(token: Token): m.Node[] {
return convertAll(token.children ?? [])
}
function convertAll(tokens: Token[]) {
return tokens.reduce((acc: m.Node[], n: Token) => acc.concat(convertNode(n)), [])
return tokens.reduce(
(acc: m.Node[], n: Token) => acc.concat(convertNode(n)),
[],
)
}

export default function mdConvert(code: string): m.Document {
Expand Down
Loading

0 comments on commit 7bf9d9d

Please sign in to comment.