Skip to content

Commit

Permalink
chore: replace eslint and prettier with biome
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfsousa committed Jun 30, 2024
1 parent 0c65cfc commit 87cff3d
Show file tree
Hide file tree
Showing 31 changed files with 3,853 additions and 9,388 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

20 changes: 0 additions & 20 deletions .eslintrc

This file was deleted.

14 changes: 7 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js 18.x
- name: Use Node.js 20.15
uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: "20.15"

- name: Cache npm
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -22,13 +22,13 @@ jobs:
- name: Install packages
run: npm ci

- name: Run lint
run: npm run lint
- name: Check lint and format errors
run: npm run check:ci

- name: Run tests
run: npm run test:cov
env:
CI: 'true'
CI: "true"

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
4 changes: 2 additions & 2 deletions .github/workflows/deploy-render.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Deploy
on:
workflow_run:
workflows: ['Docker Build and Push']
workflows: ["Docker Build and Push"]
branches:
- main
types:
- completed
workflow_dispatch:
inputs:
tag:
description: 'Tag (leave empty for latest)'
description: "Tag (leave empty for latest)"
required: false

env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker-build-push.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Docker Build and Push
on:
workflow_run:
workflows: ['CI']
workflows: ["CI"]
branches:
- main
types:
Expand All @@ -26,7 +26,7 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_release_rules: chore:patch:Chores
tag_prefix: ''
tag_prefix: ""

- name: Create a GitHub release
uses: actions/create-release@v1
Expand Down
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

5 changes: 3 additions & 2 deletions .husky/pre-commit
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
set -eu

npx lint-staged
npx @biomejs/biome check --write --staged --files-ignore-unknown=true --no-errors-on-unmatched
git update-index --again
1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

5 changes: 0 additions & 5 deletions .prettierrc.cjs

This file was deleted.

7 changes: 1 addition & 6 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"42crunch.vscode-openapi",
"mermade.openapi-lint"
]
"recommendations": ["biomejs.biome", "42crunch.vscode-openapi", "mermade.openapi-lint"]
}
15 changes: 14 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
{
"javascript.preferences.importModuleSpecifier": "non-relative"
"javascript.preferences.importModuleSpecifier": "non-relative",
"editor.codeActionsOnSave": {
"quickfix.biome": "explicit",
"source.organizeImports.biome": "explicit"
},
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[jsonc]": {
"editor.defaultFormatter": "biomejs.biome"
}
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN npm ci --omit=dev
COPY . .

FROM base-dev AS development
CMD ["node", "--env-file=.env", "--require=./src/lib/tracing.cjs", "--watch", "bin/www.js"]
CMD ["node", "--require=./src/lib/tracing.cjs", "--watch", "bin/www.js"]

FROM gcr.io/distroless/nodejs20-debian12:20.15 AS production
WORKDIR /app
Expand Down
53 changes: 53 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"ignore": ["coverage"],
"rules": {
"recommended": true,
"correctness": {
"noUnusedImports": "error"
},
"style": {
// TODO: enable "useNamingConvention": "error",
"useForOf": "error",
"noNegationElse": "error",
"useCollapsedElseIf": "error",
"useFilenamingConvention": {
"level": "error",
"options": {
"filenameCases": ["kebab-case"]
}
}
},
"suspicious": {
"noEmptyBlockStatements": "error"
},
"nursery": {
"useThrowOnlyError": "error",
"useThrowNewError": "error",
"useDateNow": "error",
"useConsistentBuiltinInstantiation": "error",
"useErrorMessage": "error",
"useExplicitLengthCheck": "error"
}
}
},
"formatter": {
"enabled": true,
"ignore": ["coverage"],
"lineWidth": 100,
"indentStyle": "space",
"indentWidth": 2
},
"javascript": {
"formatter": {
"semicolons": "asNeeded",
"quoteStyle": "single",
"arrowParentheses": "asNeeded"
}
}
}
25 changes: 15 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ x-logging: &default-logging
source_labels: ["container_name"]
target_label: instance
version: '3.9'
services:
api:
build:
Expand All @@ -22,25 +21,31 @@ services:
- .env
ports:
- 8000:8000
volumes:
- .:/app
- /app/node_modules
labels:
namespace: app
logging: *default-logging
depends_on:
- db
develop:
watch:
- action: sync
path: ./
target: /app
ignore:
- node_modules/
- action: rebuild
path: package-lock.json

db:
image: mongo:6
image: mongo:7
ports:
- 27017:27017
labels:
namespace: app
logging: *default-logging

prometheus:
profiles: ['o11y']
profiles: ["o11y"]
image: prom/prometheus:v2.39.1
ports:
- 9090:9090
Expand All @@ -55,7 +60,7 @@ services:
logging: *default-logging

loki:
profiles: ['o11y']
profiles: ["o11y"]
image: grafana/loki:2.6.1
command: -config.file=/etc/loki/loki.yaml
ports:
Expand All @@ -73,7 +78,7 @@ services:
# logging: *default-logging

tempo:
profiles: ['o11y']
profiles: ["o11y"]
image: grafana/tempo:1.5.0
command: -config.file=/etc/tempo.yaml
volumes:
Expand All @@ -87,7 +92,7 @@ services:
logging: *default-logging

tempo-query:
profiles: ['o11y']
profiles: ["o11y"]
image: grafana/tempo-query:1.5.0
command: --grpc-storage-plugin.configuration-file=/etc/tempo-query.yaml
volumes:
Expand All @@ -101,7 +106,7 @@ services:
- tempo

grafana:
profiles: ['o11y']
profiles: ["o11y"]
image: grafana/grafana:9.2.2
volumes:
- ./config/grafana-datasources.yaml:/etc/grafana/provisioning/datasources/datasource.yaml
Expand Down
Loading

0 comments on commit 87cff3d

Please sign in to comment.