Skip to content

Commit

Permalink
chore: Replace ESLint and Prettier to Biome (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
m1sk9 authored Jul 20, 2024
1 parent 0851aec commit b7afce2
Show file tree
Hide file tree
Showing 55 changed files with 538 additions and 1,476 deletions.
5 changes: 4 additions & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["github>pulsate-dev/renovate-conf"]
"extends": [
"github>pulsate-dev/renovate-conf",
"customManagers:biomeVersions"
]
}
12 changes: 4 additions & 8 deletions .github/workflows/ci.yaml → .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Build CI

on:
push:
Expand All @@ -9,7 +9,7 @@ on:
- main

jobs:
node:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -32,13 +32,9 @@ jobs:
run: |
pnpm check:type
- name: Run fmt
- name: Run biome check
run: |
pnpm check:format
- name: Run lint
run: |
pnpm lint
pnpm biome ci
- name: Run ls-lint
run: |
Expand Down
1 change: 0 additions & 1 deletion .ls-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ ignore:
- coverage
- build
- vite.config.ts
- eslint.config.js
10 changes: 0 additions & 10 deletions .prettierrc

This file was deleted.

3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"biomejs.biome",
"yzhang.markdown-all-in-one",
"EditorConfig.EditorConfig"
]
Expand Down
14 changes: 6 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
// editor settings
"editor.defaultFormatter": "esbenp.prettier-vscode",
"biome.enabled": true,
"editor.formatOnSave": true,

// Markdown All in One settings
"editor.defaultFormatter": "biomejs.biome",
"markdown.extension.toc.levels": "2..6",

// prettier extension settings
"prettier.requireConfig": true,
"prettier.configPath": ".prettierrc"
"editor.codeActionsOnSave": {
"source.organizeImports.biome": "explicit",
"quickfix.biome": "explicit"
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pulsate

[![Build CI Badge](https://github.com/pulsate-dev/pulsate/actions/workflows/ci.yaml/badge.svg)](https://github.com/pulsate-dev/pulsate/actions/workflows/ci.yaml)
[![Build CI Badge](https://github.com/pulsate-dev/pulsate/actions/workflows/build.yaml/badge.svg)](https://github.com/pulsate-dev/pulsate/actions/workflows/build.yaml)
[![Discord Badge](https://img.shields.io/discord/1155472831744856164?label=Discord&color=5865F2)](https://link.pulsate.dev/discord)
[![Follow Badge](https://img.shields.io/badge/Follow_me!-black?logo=x&logoColor=white)](https://link.pulsate.dev/x)
[![License Badge](https://img.shields.io/static/v1?label=Licence&message=Apache-2.0&color=BF485A)](./LICENSE)
Expand Down
46 changes: 46 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
// general
"files": {
"ignore": ["build/**"],
"include": ["pkg/**", "scripts/**"]
},

// formatter
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 80,
"attributePosition": "auto"
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "all",
"semicolons": "always",
"arrowParentheses": "always",
"bracketSpacing": true,
"bracketSameLine": false,
"quoteStyle": "single",
"attributePosition": "auto"
}
},
"organizeImports": {
"enabled": true
},

// linter
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noShadowRestrictedNames": "off"
}
}
}
}
66 changes: 0 additions & 66 deletions eslint.config.js

This file was deleted.

8 changes: 3 additions & 5 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
pre-commit:
commands:
check:format:
check:
glob: '*.{js,ts,md}'
run: pnpm run check:format
# Run `pnpm biome check` for all files (formatter and linter)
run: pnpm biome check
check:filename:
glob: '*.{js,ts}'
run: pnpm run check:filename
lint:
glob: '*.{js,ts,md}'
run: pnpm run lint
17 changes: 4 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
"build:api": "node ./build/scripts/apidoc.js",
"build:prisma": "prisma generate",
"clean": "rm -r ./build",
"format": "prettier --write \"./**/*.{js,ts,md}\"",
"lint": "eslint . ",
"format": "biome format --write .",
"lint": "biome lint .",
"test": "vitest run",
"test:coverage": "vitest run --coverage",
"check:type": "tsc -p .",
"check:filename": "ls-lint",
"check:format": "prettier --check \"./**/*.{js,ts,md}\"",
"check:format": "biome format \"./**/*.{js,ts,md}\"",
"prepare": "pnpm run build:prisma",
"postinstall": "lefthook install"
},
Expand All @@ -48,24 +48,15 @@
"typescript": "^5.3.3"
},
"devDependencies": {
"@eslint/eslintrc": "^3.0.0",
"@eslint/js": "^9.0.0",
"@biomejs/biome": "^1.8.3",
"@ls-lint/ls-lint": "^2.2.3",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/node": "^20.11.16",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"@vitest/coverage-v8": "^2.0.0",
"esbuild": "^0.23.0",
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-vitest": "^0.5.0",
"glob": "^11.0.0",
"globals": "^15.0.0",
"ignore": "^5.3.1",
"kleur": "^4.1.5",
"lefthook": "^1.6.1",
"prettier": "^3.2.5",
"vitest": "^2.0.0"
}
}
20 changes: 10 additions & 10 deletions pkg/accounts/adaptor/controller/account.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type z } from '@hono/zod-openapi';
import type { z } from '@hono/zod-openapi';
import { Option, Result } from '@mikuroxina/mini-fn';

import { type AccountID, type AccountName } from '../../model/account.js';
import type { AccountID, AccountName } from '../../model/account.js';
import type { AuthenticateService } from '../../service/authenticate.js';
import type { EditService } from '../../service/edit.js';
import type { FetchService } from '../../service/fetch.js';
Expand All @@ -11,15 +11,15 @@ import type { FreezeService } from '../../service/freeze.js';
import type { RegisterService } from '../../service/register.js';
import type { ResendVerifyTokenService } from '../../service/resendToken.js';
import type { SilenceService } from '../../service/silence.js';
import { type UnfollowService } from '../../service/unfollow.js';
import type { UnfollowService } from '../../service/unfollow.js';
import type { VerifyAccountTokenService } from '../../service/verifyToken.js';
import {
type CreateAccountResponseSchema,
type GetAccountFollowerSchema,
type GetAccountFollowingSchema,
type GetAccountResponseSchema,
type LoginResponseSchema,
type UpdateAccountResponseSchema,
import type {
CreateAccountResponseSchema,
GetAccountFollowerSchema,
GetAccountFollowingSchema,
GetAccountResponseSchema,
LoginResponseSchema,
UpdateAccountResponseSchema,
} from '../validator/schema.js';

export class AccountController {
Expand Down
8 changes: 4 additions & 4 deletions pkg/accounts/adaptor/repository/dummy.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Ether, Option, Result } from '@mikuroxina/mini-fn';

import { type Account, type AccountID } from '../../model/account.js';
import { type AccountFollow } from '../../model/follow.js';
import type { Account, AccountID } from '../../model/account.js';
import type { AccountFollow } from '../../model/follow.js';
import type { InactiveAccount } from '../../model/inactiveAccount.js';
import {
type AccountFollowRepository,
type AccountRepository,
accountRepoSymbol,
type AccountVerifyTokenRepository,
followRepoSymbol,
type InactiveAccountRepository,
accountRepoSymbol,
followRepoSymbol,
inactiveAccountRepoSymbol,
verifyTokenRepoSymbol,
} from '../../model/repository.js';
Expand Down
4 changes: 2 additions & 2 deletions pkg/accounts/adaptor/repository/prisma.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Ether, Option, Result } from '@mikuroxina/mini-fn';
import { type Prisma, type PrismaClient } from '@prisma/client';
import type { Prisma, PrismaClient } from '@prisma/client';

import type { prismaClient } from '../../../adaptors/prisma.js';
import {
Expand All @@ -15,8 +15,8 @@ import { AccountFollow } from '../../model/follow.js';
import {
type AccountFollowRepository,
type AccountRepository,
accountRepoSymbol,
type AccountVerifyTokenRepository,
accountRepoSymbol,
followRepoSymbol,
verifyTokenRepoSymbol,
} from '../../model/repository.js';
Expand Down
4 changes: 2 additions & 2 deletions pkg/accounts/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { OpenAPIHono } from '@hono/zod-openapi';
import { Cat, Ether, Promise, Result } from '@mikuroxina/mini-fn';

import {
authenticateMiddleware,
type AuthMiddlewareVariable,
authenticateMiddleware,
} from '../adaptors/authenticateMiddleware.js';
import { prismaClient } from '../adaptors/prisma.js';
import { clockSymbol, snowflakeIDGenerator } from '../id/mod.js';
Expand All @@ -21,7 +21,7 @@ import {
prismaFollowRepo,
prismaVerifyTokenRepo,
} from './adaptor/repository/prisma.js';
import { type AccountName } from './model/account.js';
import type { AccountName } from './model/account.js';
import { accountRepoSymbol } from './model/repository.js';
import {
CreateAccountRoute,
Expand Down
2 changes: 1 addition & 1 deletion pkg/accounts/model/inactiveAccount.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';

import { type AccountID, type CreateAccountArgs } from './account.js';
import type { AccountID, CreateAccountArgs } from './account.js';
import {
type CreateInactiveAccountArgs,
InactiveAccount,
Expand Down
5 changes: 1 addition & 4 deletions pkg/accounts/model/inactiveAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ export type ActivateArgs = Omit<
>;

export class AlreadyActivatedError extends Error {
constructor(message?: string) {
if (message) {
super('This account was already activated.');
}
constructor(message = 'This account was already activated.') {
super(message);
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/accounts/model/repository.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Ether, type Option, type Result } from '@mikuroxina/mini-fn';

import type { Account } from './account.js';
import { type AccountID } from './account.js';
import type { AccountID } from './account.js';
import type { AccountFollow } from './follow.js';
import type { InactiveAccount } from './inactiveAccount.js';

Expand Down
5 changes: 3 additions & 2 deletions pkg/accounts/service/authenticate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { AuthenticationTokenService } from './authenticationTokenService.js';
describe('AuthenticateService', () => {
it('Generate valid token pair', async () => {
const encoder = new Argon2idPasswordEncoder();
const passphraseHash =
await encoder.encodePassword('じゃすた・いぐざんぽぅ');
const passphraseHash = await encoder.encodePassword(
'じゃすた・いぐざんぽぅ',
);

const accountRepository = new InMemoryAccountRepository();
await accountRepository.create(
Expand Down
Loading

0 comments on commit b7afce2

Please sign in to comment.