Skip to content

Commit

Permalink
Switch to biome (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
kibertoad authored Jul 19, 2024
1 parent 65888d5 commit e25ee9a
Show file tree
Hide file tree
Showing 20 changed files with 97 additions and 159 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

76 changes: 0 additions & 76 deletions .eslintrc.json

This file was deleted.

2 changes: 0 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ updates:
- 'skip-release'
ignore:
- dependency-name: 'dot-prop'
- dependency-name: 'eslint'
- dependency-name: 'eslint-plugin-vitest'
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ lib/
jest.config.json
package-lock.json
tsconfig.json
.eslintrc.json
biome.json
3 changes: 0 additions & 3 deletions .prettierignore

This file was deleted.

9 changes: 0 additions & 9 deletions .prettierrc.json

This file was deleted.

7 changes: 7 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": ".node_modules/@biomejs/biome/configuration_schema.json",
"extends": [
"./node_modules/@lokalise/biome-config/configs/biome-base.jsonc",
"./node_modules/@lokalise/biome-config/configs/biome-package.jsonc"
]
}
26 changes: 9 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
"url": "git://github.com/lokalise/node-core.git"
},
"license": "Apache-2.0",
"files": [
"dist/**",
"LICENSE",
"README.md"
],
"files": ["dist/**", "LICENSE", "README.md"],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "commonjs",
Expand All @@ -28,32 +24,28 @@
"test:coverage": "vitest --coverage",
"test:ci": "npm run lint && npm run test:coverage",
"test:update-snapshots": "vitest -u",
"lint": "eslint . --ext .ts && prettier --check --log-level warn \"**/*.{json,md,ts}\" !CHANGELOG.md",
"lint:fix": "eslint . --fix && prettier --write --log-level warn \"**/*.{json,md,ts}\" !CHANGELOG.md",
"lint": "biome check . && tsc --project tsconfig.lint.json --noEmit",
"lint:fix": "biome check --write",
"version": "auto-changelog -p && git add CHANGELOG.md",
"prepublishOnly": "npm run build"
},
"dependencies": {
"dot-prop": "6.0.1",
"pino": "^9.1.0",
"pino": "^9.3.1",
"pino-pretty": "^11.2.1",
"tslib": "^2.6.2",
"tslib": "^2.6.3",
"zod": "^3.23.8"
},
"devDependencies": {
"@types/node": "^20.14.2",
"@biomejs/biome": "^1.8.3",
"@lokalise/biome-config": "^1.3.0",
"@types/node": "^20.14.11",
"@types/tmp": "^0.2.6",
"@typescript-eslint/eslint-plugin": "^7.12.0",
"@typescript-eslint/parser": "^7.12.0",
"@vitest/coverage-v8": "2.0.3",
"auto-changelog": "^2.4.0",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-vitest": "0.4.1",
"pino-test": "^1.0.1",
"prettier": "^3.3.1",
"tmp": "^0.2.3",
"typescript": "^5.4.5",
"typescript": "^5.5.3",
"vitest": "2.0.3"
}
}
2 changes: 1 addition & 1 deletion src/common/commonTypes.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// eslint-disable-next-line @typescript-eslint/no-explicit-any
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
export type FreeformRecord = Record<string, any>
21 changes: 21 additions & 0 deletions src/config/ConfigScope.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('ConfigScope', () => {
})

it('throws an error on missing value', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand Down Expand Up @@ -67,6 +68,7 @@ describe('ConfigScope', () => {
})

it('throws an error on missing value', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand Down Expand Up @@ -96,6 +98,7 @@ describe('ConfigScope', () => {
})

it('throws an error on missing value', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand Down Expand Up @@ -125,6 +128,7 @@ describe('ConfigScope', () => {
})

it('throws an error on missing value', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand All @@ -145,6 +149,7 @@ describe('ConfigScope', () => {
})

it('uses default value if not set', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand All @@ -154,6 +159,7 @@ describe('ConfigScope', () => {
})

it('keeps null if preferred', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand Down Expand Up @@ -183,6 +189,7 @@ describe('ConfigScope', () => {
})

it('uses default value if not set', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand Down Expand Up @@ -261,6 +268,7 @@ describe('ConfigScope', () => {
})

it('returns default if env value not exists and the default one exists on the list', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand All @@ -279,6 +287,7 @@ describe('ConfigScope', () => {
})

it('throws an error if env value not exists and the default one not exists on the list', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand All @@ -299,6 +308,7 @@ describe('ConfigScope', () => {
})

it('uses default value if not set', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand Down Expand Up @@ -331,6 +341,7 @@ describe('ConfigScope', () => {
})

it('uses default value if not set', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand All @@ -349,6 +360,7 @@ describe('ConfigScope', () => {
})

it('throws when default value fails validation', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand All @@ -369,6 +381,7 @@ describe('ConfigScope', () => {
})

it('uses default value if not set', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand All @@ -378,6 +391,7 @@ describe('ConfigScope', () => {
})

it('uses default undefined value if not set', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand All @@ -387,6 +401,7 @@ describe('ConfigScope', () => {
})

it('uses default null value if not set', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand All @@ -411,6 +426,7 @@ describe('ConfigScope', () => {
})

it('uses default value if not set', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand Down Expand Up @@ -453,6 +469,7 @@ describe('ConfigScope', () => {
})

it('uses default value if not set', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand Down Expand Up @@ -494,6 +511,7 @@ describe('ConfigScope', () => {
})

it('uses default value if not set', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand All @@ -507,6 +525,7 @@ describe('ConfigScope', () => {
})

it('uses default undefined value if not set', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand Down Expand Up @@ -547,6 +566,7 @@ describe('ConfigScope', () => {
})

it('throws an error if not set', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand Down Expand Up @@ -576,6 +596,7 @@ describe('ConfigScope', () => {
})

it('uses default value if not set', () => {
// biome-ignore lint/performance/noDelete: <explanation>
delete process.env.value
const configScope = new ConfigScope()

Expand Down
6 changes: 3 additions & 3 deletions src/errors/globalErrorHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { types } from 'node:util'

import type { SerializedError } from 'pino'
import { pino, levels, stdSerializers } from 'pino'
import { levels, pino, stdSerializers } from 'pino'

import type { CommonLogger } from '../logging/commonLogger'
import { hasMessage } from '../utils/typeUtils'
Expand All @@ -14,7 +14,7 @@ type LogObject = {

export const globalLogger: CommonLogger = pino({
formatters: {
level: (label, numericLevel): { level: string } => {
level: (_label, numericLevel): { level: string } => {
const level = levels.labels[numericLevel] || 'unknown'
return { level }
},
Expand Down Expand Up @@ -76,7 +76,7 @@ export async function executeSettleAllAndHandleGlobalErrors(
) {
const result = await Promise.allSettled(promises)

let errorsHappened
let errorsHappened: boolean | undefined
for (const entry of result) {
if (entry.status === 'rejected') {
const logObject = resolveGlobalErrorLogObject(entry.reason)
Expand Down
6 changes: 2 additions & 4 deletions src/logging/loggerConfigResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type MonorepoAppLoggerConfig = AppLoggerConfig & {
/* c8 ignore next 25 */
export function resolveMonorepoLoggerConfiguration(
appConfig: MonorepoAppLoggerConfig,
): LoggerOptions | Logger | boolean {
): LoggerOptions | Logger {
if (appConfig.nodeEnv !== 'development') {
return resolveLoggerConfiguration(appConfig)
}
Expand All @@ -42,9 +42,7 @@ export function resolveMonorepoLoggerConfiguration(
}
}

export function resolveLoggerConfiguration(
appConfig: AppLoggerConfig,
): LoggerOptions | Logger | boolean {
export function resolveLoggerConfiguration(appConfig: AppLoggerConfig): LoggerOptions | Logger {
if (appConfig.nodeEnv !== 'production') {
return pino(
pretty({
Expand Down
1 change: 1 addition & 0 deletions src/utils/arrayUtils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it, vitest } from 'vitest'
import { callChunked, chunk, removeFalsy, removeNullish } from './arrayUtils'

describe('arrayUtils', () => {
Expand Down
Loading

0 comments on commit e25ee9a

Please sign in to comment.