Skip to content

Commit

Permalink
feat: replace prettier and eslint with biome
Browse files Browse the repository at this point in the history
  • Loading branch information
soofstad committed Jun 6, 2024
1 parent ddbb339 commit afe2cb9
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 126 deletions.
52 changes: 8 additions & 44 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,58 +37,22 @@ repos:
- id: conventional-pre-commit
stages: [commit-msg]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.289"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.7"
hooks:
- id: ruff
name: Code linting
name: Python format
files: ^api/.*\.py$
args:
- --fix

- repo: https://github.com/ambv/black
rev: 23.9.1
- repo: https://github.com/biomejs/pre-commit
rev: v0.2.0
hooks:
- id: black
name: Code formatting
language_version: python3.10
args: [--config=api/pyproject.toml]
files: ^api/src/.*\.py$

- repo: https://github.com/econchick/interrogate
rev: 1.5.0
hooks:
- id: interrogate
language_version: python3.10
types: [python]
args: [--config=api/pyproject.toml]
files: ^api/.*\.py$
- id: biome-check
additional_dependencies: [ "@biomejs/[email protected]" ]
args: ["--config-path", "web"]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
hooks:
- id: prettier
files: ^web/src/.*\.(ts|tsx|js|css|html|json)$
args:
["--config=web/.prettierrc.js", "--ignore-path=web/.prettierignore"]

- repo: https://github.com/pre-commit/mirrors-eslint
rev: "v8.49.0"
hooks:
- id: eslint
additional_dependencies:
- eslint
- typescript
- "@typescript-eslint/parser"
- "@typescript-eslint/eslint-plugin"
- eslint-config-prettier # turns off all rules that might conflict with prettier
- eslint-plugin-jsx-a11y # checks accessibility rules on jsx elements
- eslint-plugin-prettier # runs prettier as an eslint rule
- eslint-plugin-react # react specific linting rules
- eslint-plugin-react-hooks # enforces the rules of hooks
files: ^web/src/.*\.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx
types: [file]
args: ["--config=web/.eslintrc.json", "--ignore-path=web/.eslintignore"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
Expand Down
15 changes: 0 additions & 15 deletions api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,6 @@ pre-commit = ">=3"
pytest = "^7.2.2"
mongomock = "^4.1.2"

[tool.black]
line-length = 119
target-version = ['py310']
include = '\.pyi?$'
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
)/
'''

[tool.interrogate]
ignore-init-method = true
ignore-init-module = true
Expand Down
4 changes: 2 additions & 2 deletions api/src/common/exception_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def add_exception_handlers(app: FastAPI) -> None:
app.add_exception_handler(MissingPrivilegeException, generic_exception_handler)

# Override built-in default handler
app.add_exception_handler(RequestValidationError, validation_exception_handler)
app.add_exception_handler(HTTPStatusError, http_exception_handler)
app.add_exception_handler(RequestValidationError, validation_exception_handler) # type: ignore
app.add_exception_handler(HTTPStatusError, http_exception_handler) # type: ignore

# Fallback exception handler for all unexpected exceptions
app.add_exception_handler(Exception, fall_back_exception_handler)
Expand Down
6 changes: 0 additions & 6 deletions web/.eslintignore

This file was deleted.

39 changes: 0 additions & 39 deletions web/.eslintrc.json

This file was deleted.

6 changes: 0 additions & 6 deletions web/.prettierignore

This file was deleted.

7 changes: 0 additions & 7 deletions web/.prettierrc.js

This file was deleted.

34 changes: 34 additions & 0 deletions web/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.0/schema.json",
"files": {
"ignore": ["documentation/*", "api/*", "web/src/api/generated"]
},
"javascript": {
"formatter": {
"indentStyle": "space",
"indentWidth": 2,
"jsxQuoteStyle": "single",
"quoteStyle": "single",
"trailingCommas": "es5",
"lineWidth": 119,
"semicolons": "asNeeded"
}
},
"json": {
"formatter": {
"indentStyle": "space",
"indentWidth": 2
}
},
"linter": {
"rules": {
"a11y": {
"useButtonType": "off"
},
"correctness": {
"useExhaustiveDependencies": "off",
"noVoidTypeReturn": "off"
}
}
}
}
6 changes: 1 addition & 5 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
"lint": "yarn eslint --fix --ext .ts,.tsx ."
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"production": [">0.2%", "not dead", "not op_mini all"],
"development": [
"last 1 chrome version",
"last 1 firefox version",
Expand Down
4 changes: 2 additions & 2 deletions web/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import checker from 'vite-plugin-checker'
import react from '@vitejs/plugin-react'
import viteTsConfigPaths from 'vite-tsconfig-paths'
import svgrPlugin from 'vite-plugin-svgr'
import viteTsConfigPaths from 'vite-tsconfig-paths'

export default defineConfig({
plugins: [
Expand Down

0 comments on commit afe2cb9

Please sign in to comment.