Skip to content

Commit

Permalink
feat: replace prettier + eslint w/ biome (#91)
Browse files Browse the repository at this point in the history
* feat;

* fix: lint fix
  • Loading branch information
gairal authored Aug 4, 2024
1 parent 657c412 commit 56debbf
Show file tree
Hide file tree
Showing 26 changed files with 73 additions and 138 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

84 changes: 0 additions & 84 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
with:
bun-version: latest
- run: bun i --frozen-lockfile
- run: bun lint
- run: bun biome ci --diagnostic-level=error
- run: bun run build
- run: bun test-cov
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# [frank.gairal.rocks](https://frank.gairal.rocks) RESTful API ![CI status](https://github.com/gairal/frank-bo-node/actions/workflows/ci.yml/badge.svg)

> A REST API built with [TypeScript](https://www.typescriptlang.org/), [Koa](https://koajs.com/),
> [Jest](https://jestjs.io/), [Prettier](https://prettier.io/), [eslint](https://eslint.org/) and ❤️
> [Jest](https://jestjs.io/), [bun](https://bun.sh/), [biome](https://biomejs.dev/) and ❤️
## TOC

Expand Down
36 changes: 36 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"files": {
"ignore": ["dist", "node_modules"]
},
"formatter": {
"indentStyle": "space"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"all": true,
"correctness": { "noNodejsModules": "off" },
"nursery": {
"all": true,
"useImportExtensions": "off",
"useImportRestrictions": "off"
},
"performance": { "noBarrelFile": "off", "noReExportAll": "off" }
}
},
"javascript": {
"globals": ["afterAll", "beforeAll", "describe", "expect", "it"]
},
"overrides": [
{
"include": ["lint-staged.config.js"],
"linter": {
"rules": { "style": { "useFilenamingConvention": "off" } }
}
}
]
}
Binary file modified bun.lockb
Binary file not shown.
19 changes: 4 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,26 @@
"deploy": "gcloud app deploy --project com-gairal-frank-22",
"dev": "bun run --hot --inspect ./src/index.ts",
"gcp-build": "npm run build",
"lint": "eslint . --ext .js,.ts --quiet",
"lint": "biome check",
"prepare": "husky",
"start": "node dist",
"test": "LOG_LEVEL=error jest",
"test-cov": "bun run test --collectCoverage"
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@tsconfig/node20": "^20.1.4",
"@types/jest": "^29.5.12",
"@types/koa": "^2.15.0",
"@types/koa-logger": "^3.1.5",
"@types/koa__cors": "^5.0.0",
"@types/koa__router": "^12.0.4",
"@types/node": "^22.1.0",
"@types/supertest": "^6.0.2",
"eslint": "^8.57.0",
"eslint-config-airbnb-typescript-prettier": "^5.0.0",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-sort-keys-fix": "^1.1.2",
"eslint-plugin-testing-library": "^6.2.2",
"eslint-plugin-typescript-sort-keys": "^3.2.0",
"firestore-jest-mock": "^0.25.0",
"husky": "^9.1.4",
"jest": "^29.7.0",
"lint-staged": "^15.2.8",
"prettier": "^2.8.8",
"supertest": "^7.0.0",
"ts-jest": "^29.2.3",
"typescript": "^5.5.4"
Expand All @@ -51,11 +45,6 @@
"winston": "^3.13.1"
},
"lint-staged": {
"*.{js,cjs,ts,svelte}": [
"eslint --cache --fix"
],
"*.{json,scss,css,md}": [
"prettier --write"
]
"*.{js,cjs,ts,json,md,lint}": ["bun lint --fix"]
}
}
8 changes: 4 additions & 4 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import cors from "@koa/cors";
import Koa from "koa";
import helmet from "koa-helmet";
import logger from "koa-logger";
import cors from "@koa/cors";

import { LOG_LEVEL } from "./env";
import { errorHandler } from "./lib/errorHandler";
import { educationRouter } from "./routes/education";
import { interestRouter } from "./routes/interest";
import { skillRouter } from "./routes/skill";
import { travelRouter } from "./routes/travel";
import { workRouter } from "./routes/work";
import { LOG_LEVEL } from "./env";
import { errorHandler } from "./lib/errorHandler";

export const app = new Koa();

Expand All @@ -28,7 +28,7 @@ app.use(
ctx.header.origin?.includes("gairal.")
? ctx.header.origin
: "http://localhost:3000",
})
}),
);

/** ROUTES */
Expand Down
2 changes: 1 addition & 1 deletion src/lib/errorHandler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Middleware } from "koa";
import type { Middleware } from "koa";

import { logger } from "./logger";

Expand Down
4 changes: 2 additions & 2 deletions src/model/education.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { QueryDocumentSnapshot } from "@google-cloud/firestore";
import type { QueryDocumentSnapshot } from "@google-cloud/firestore";

import { Education, FirestoreEducation } from "../types/education";
import { firestore } from "../lib/db";
import type { Education, FirestoreEducation } from "../types/education";

const collection = firestore.collection("education").withConverter<Education>({
fromFirestore: (snapshot: QueryDocumentSnapshot<FirestoreEducation>) => {
Expand Down
4 changes: 2 additions & 2 deletions src/model/interest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { QueryDocumentSnapshot } from "@google-cloud/firestore";
import type { QueryDocumentSnapshot } from "@google-cloud/firestore";

import { firestore } from "../lib/db";
import { FirestoreInterest, Interest } from "../types/interest";
import type { FirestoreInterest, Interest } from "../types/interest";

const collection = firestore.collection("interest").withConverter<Interest>({
fromFirestore: (snapshot: QueryDocumentSnapshot<FirestoreInterest>) => {
Expand Down
10 changes: 5 additions & 5 deletions src/model/skill.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { QueryDocumentSnapshot } from "@google-cloud/firestore";
import type { QueryDocumentSnapshot } from "@google-cloud/firestore";

import { firestore } from "../lib/db";
import { FirestoreSkillByCategory, SkillByCategory } from "../types/skill";
import type { FirestoreSkillByCategory, SkillByCategory } from "../types/skill";

const collection = firestore
.collection("skill")
.withConverter<SkillByCategory>({
fromFirestore: (
snapshot: QueryDocumentSnapshot<FirestoreSkillByCategory>
snapshot: QueryDocumentSnapshot<FirestoreSkillByCategory>,
) => {
const { order, ...rest } = snapshot.data();
return rest;
Expand All @@ -23,9 +23,9 @@ export const getAll = () =>
docs.map((doc) => {
const data = doc.data();
data.skills.sort(
({ level: levelA = 0 }, { level: levelB = 0 }) => levelB - levelA
({ level: levelA = 0 }, { level: levelB = 0 }) => levelB - levelA,
);

return data;
})
}),
);
4 changes: 2 additions & 2 deletions src/model/travel.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { QueryDocumentSnapshot } from "@google-cloud/firestore";
import type { QueryDocumentSnapshot } from "@google-cloud/firestore";

import { firestore } from "../lib/db";
import { FirestoreTravel, Travel } from "../types/travel";
import type { FirestoreTravel, Travel } from "../types/travel";

const collection = firestore.collection("travel").withConverter<Travel>({
fromFirestore: (snapshot: QueryDocumentSnapshot<FirestoreTravel>) => {
Expand Down
4 changes: 2 additions & 2 deletions src/model/work.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { QueryDocumentSnapshot } from "@google-cloud/firestore";
import type { QueryDocumentSnapshot } from "@google-cloud/firestore";

import { firestore } from "../lib/db";
import { FirestoreWork, Work } from "../types/work";
import type { FirestoreWork, Work } from "../types/work";

const collection = firestore.collection("work").withConverter<Work>({
fromFirestore: (snapshot: QueryDocumentSnapshot<FirestoreWork>) => {
Expand Down
2 changes: 1 addition & 1 deletion src/types/category.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DocumentData } from "@google-cloud/firestore";
import type { DocumentData } from "@google-cloud/firestore";

export interface FirestoreCategory extends DocumentData {
label: string;
Expand Down
2 changes: 1 addition & 1 deletion src/types/education.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DocumentData, Timestamp } from "@google-cloud/firestore";
import type { DocumentData, Timestamp } from "@google-cloud/firestore";

export interface FirestoreEducation extends DocumentData {
dateIn: Timestamp;
Expand Down
2 changes: 1 addition & 1 deletion src/types/interest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DocumentData } from "@google-cloud/firestore";
import type { DocumentData } from "@google-cloud/firestore";

export interface FirestoreInterest extends DocumentData {
description?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/types/skill.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FirestoreCategory } from "./category";
import type { FirestoreCategory } from "./category";

export interface FirestoreSkillByCategory extends FirestoreCategory {
skills: { description?: string; label: string; level?: number }[];
Expand Down
2 changes: 1 addition & 1 deletion src/types/travel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DocumentData, GeoPoint } from "@google-cloud/firestore";
import type { DocumentData, GeoPoint } from "@google-cloud/firestore";

export interface FirestoreTravel extends DocumentData {
coordinates: GeoPoint;
Expand Down
2 changes: 1 addition & 1 deletion src/types/work.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DocumentData, Timestamp } from "@google-cloud/firestore";
import type { DocumentData, Timestamp } from "@google-cloud/firestore";

export interface FirestoreWork extends DocumentData {
achievements: { description: string; highlights?: string[] }[];
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/education.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Timestamp } from "@google-cloud/firestore";

import { FirestoreEducation } from "../../src/types/education";
import type { FirestoreEducation } from "../../src/types/education";

export const educationFixture = (): FirestoreEducation[] => [
{
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/interest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FirestoreInterest } from "../../src/types/interest";
import type { FirestoreInterest } from "../../src/types/interest";

export const interestFixture = (): FirestoreInterest[] => [
{
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/skill.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FirestoreSkillByCategory } from "../../src/types/skill";
import type { FirestoreSkillByCategory } from "../../src/types/skill";

export const skillFixture = (): FirestoreSkillByCategory[] => [
{
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/travel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GeoPoint } from "@google-cloud/firestore";

import { FirestoreTravel } from "../../src/types/travel";
import type { FirestoreTravel } from "../../src/types/travel";

export const travelFixture = (): FirestoreTravel[] => [
{
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/work.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Timestamp } from "@google-cloud/firestore";

import { FirestoreWork } from "../../src/types/work";
import type { FirestoreWork } from "../../src/types/work";

export const workFixture = (): FirestoreWork[] => [
{
Expand Down
9 changes: 2 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
{
"extends": "@tsconfig/node20/tsconfig.json",
"compilerOptions": {
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"lib": ["ES2023"],
"module": "commonjs",
"outDir": "./dist",
"skipLibCheck": true,
"strict": true,
"target": "ES2022"
"outDir": "./dist"
},
"exclude": [
"./__mocks__",
Expand Down

0 comments on commit 56debbf

Please sign in to comment.