diff --git a/.vscode/settings.json b/.vscode/settings.json index 5f17ce4..3a10d3b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,10 +1,15 @@ { - "typescript.enablePromptUseWorkspaceTsdk": true, - "typescript.inlayHints.variableTypes.enabled": true, - "typescript.inlayHints.variableTypes.suppressWhenTypeMatchesName": true, - "typescript.inlayHints.parameterTypes.enabled": true, - "typescript.inlayHints.parameterNames.suppressWhenArgumentMatchesName": true, - "typescript.inlayHints.parameterNames.enabled": "all", - "typescript.preferences.preferTypeOnlyAutoImports": true, - "typescript.tsdk": "./node_modules/typescript/lib" + "editor.codeActionsOnSave": { + "source.organizeImports.biome": "explicit", + "quickfix.biome": "explicit" + }, + "editor.defaultFormatter": "biomejs.biome", + "typescript.enablePromptUseWorkspaceTsdk": true, + "typescript.inlayHints.variableTypes.enabled": true, + "typescript.inlayHints.variableTypes.suppressWhenTypeMatchesName": true, + "typescript.inlayHints.parameterTypes.enabled": true, + "typescript.inlayHints.parameterNames.suppressWhenArgumentMatchesName": true, + "typescript.inlayHints.parameterNames.enabled": "all", + "typescript.preferences.preferTypeOnlyAutoImports": true, + "typescript.tsdk": "./node_modules/typescript/lib" } diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..5c77e3f --- /dev/null +++ b/biome.json @@ -0,0 +1,16 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.6.0/schema.json", + "organizeImports": { + "enabled": true + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true + } + }, + "formatter": { + "formatWithErrors": true, + "indentStyle": "space" + } +} diff --git a/bun.lockb b/bun.lockb index 9cb292a..99e858e 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 7fc9b3e..1bda9d2 100644 --- a/package.json +++ b/package.json @@ -9,14 +9,11 @@ "build:types": "tsc -p tsconfig.build.json", "build": "bun build:lib && bun build:types", "lint": "npm run lint:lib && npm run lint:exports && npm run lint:package", - "lint:lib": "eslint --ext .ts src", + "lint:lib": "biome check src/*.ts", "lint:exports": "attw --pack . --ignore-rules no-resolution cjs-resolves-to-esm", "lint:package": "publint ." }, - "files": [ - "dist", - "package.json" - ], + "files": ["dist", "package.json"], "exports": { ".": { "types": "./dist/index.d.ts", @@ -27,38 +24,14 @@ }, "devDependencies": { "@arethetypeswrong/cli": "0.15.1", + "@biomejs/biome": "1.6.0", "@tsconfig/strictest": "2.0.3", - "@types/bun": "^1.0.5", - "@typescript-eslint/eslint-plugin": "7.2.0", - "@typescript-eslint/parser": "7.2.0", + "@types/bun": "1.0.8", "bun-types": "1.0.30", - "eslint": "8.57.0", "publint": "0.2.7", "typescript": "5.4.2" }, "publishConfig": { "registry": "https://npm.pkg.github.com" - }, - "eslintConfig": { - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/strict-type-checked", - "plugin:@typescript-eslint/stylistic-type-checked" - ], - "plugins": [ - "@typescript-eslint" - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": true, - "tsconfigRootDir": "." - }, - "root": true, - "rules": { - "@typescript-eslint/no-empty-interface": "off", - "@typescript-eslint/explicit-function-return-type": [ - "error" - ] - } } } diff --git a/src/Option.test.ts b/src/Option.test.ts index 97214cc..1ed26c7 100644 --- a/src/Option.test.ts +++ b/src/Option.test.ts @@ -1,4 +1,4 @@ -import { expect, test, mock, describe } from "bun:test"; +import { describe, expect, mock, test } from "bun:test"; import { Option } from "./Option.ts"; @@ -31,7 +31,7 @@ describe("Option", () => { const mapper = mock((value) => `
${value}
`); const html = some.map(mapper); expect(html.isOk()).toBe(true); - expect(html.orElse(`fallback`)).toBe(`
content
`); + expect(html.orElse("fallback")).toBe("
content
"); expect(mapper).toHaveBeenCalledTimes(1); }); @@ -40,7 +40,7 @@ describe("Option", () => { const mapper = mock((value) => Option.Some(`
${value}
`)); const html = some.flatMap(mapper); expect(html.isOk()).toBe(true); - expect(html.orElse(`
fallback
`)).toBe(`
content
`); + expect(html.orElse("
fallback
")).toBe("
content
"); expect(mapper).toHaveBeenCalledTimes(1); }); }); diff --git a/src/Option.ts b/src/Option.ts index 18b6230..7c1f032 100644 --- a/src/Option.ts +++ b/src/Option.ts @@ -5,7 +5,8 @@ interface Some { value: Value; } -interface None {} +// biome-ignore lint/complexity/noBannedTypes: +type None = {}; type $Option = Some | None; diff --git a/src/Result.test.ts b/src/Result.test.ts index a78b356..dd44111 100644 --- a/src/Result.test.ts +++ b/src/Result.test.ts @@ -4,13 +4,13 @@ import { Result } from "./Result.ts"; describe("Result", () => { test("should map value without change the original reference", () => { - const content = Result.Ok(`content`); + const content = Result.Ok("content"); const html = content.map((value) => `
${value}
`); expect(html.ok().orElse("fallback")).toBe("
content
"); }); test("should correctly render when apply toString()", () => { - const content = Result.Ok(`content`); + const content = Result.Ok("content"); const html = content.map((value) => `
${value}
`); expect(html.toString()).toBe("Ok (
content
)"); }); diff --git a/src/Result.ts b/src/Result.ts index b862397..07cca5d 100644 --- a/src/Result.ts +++ b/src/Result.ts @@ -21,10 +21,10 @@ export class Result extends Container< $Result > { static Ok(value: Value): Result { - return new this({ value }); + return new Result({ value }); } static Error(error: Error): Result { - return new this({ error }); + return new Result({ error }); } isError(): boolean { return "error" in this.value; @@ -42,7 +42,7 @@ export class Result extends Container< return Result.Ok(mapper((this.value as Success).value)); } flatMap( - mapper: Mapper> + mapper: Mapper>, ): Result { if (this.isError()) { return Result.Error((this.value as Failure).error); @@ -51,7 +51,7 @@ export class Result extends Container< } match( resolve: Mapper, - reject: Mapper + reject: Mapper, ): Output { if (this.isError()) { return reject((this.value as Failure).error);