Skip to content

Commit

Permalink
Merge pull request #72 from daisugiland/replace-rome
Browse files Browse the repository at this point in the history
refactor: replace rome with biome
  • Loading branch information
sviridoff authored Sep 18, 2023
2 parents 8632b7b + e1e575a commit 8a00c06
Show file tree
Hide file tree
Showing 21 changed files with 654 additions and 436 deletions.
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"vivaxy.vscode-conventional-commits",
"yoavbls.pretty-ts-errors",
"richie5um2.vscode-sort-json",
"rome.rome"
"biomejs.biome",
"usernamehw.errorlens"
]
}
8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"[javascript]": {
"editor.defaultFormatter": "rome.rome"
"editor.defaultFormatter": "biomejs.biome"
},
"[typescript]": {
"editor.defaultFormatter": "rome.rome"
"editor.defaultFormatter": "biomejs.biome"
},
"cSpell.words": [
"anzen",
Expand Down Expand Up @@ -33,8 +33,8 @@
"**/node_modules/": true
},
"editor.codeActionsOnSave": {
"quickfix.rome": true,
"source.organizeImports.rome": true,
"quickfix.biome": true,
"source.organizeImports.biome": true,
"source.addMissingImports": true,
"source.fixAll.sortJSON": true
},
Expand Down
27 changes: 27 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "https://biomejs.dev/schemas/1.2.2/schema.json",
"formatter": {
"indentSize": 2,
"indentStyle": "space",
"lineWidth": 60
},
"javascript": {
"formatter": {
"quoteProperties": "asNeeded",
"quoteStyle": "single",
"semicolons": "always",
"trailingComma": "all"
}
},
"linter": {
"enabled": true,
"rules": {
"suspicious": {
"noExplicitAny": "off"
}
}
},
"organizeImports": {
"enabled": true
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
"node": ">= 18.15.0"
},
"devDependencies": {
"@lerna-lite/cli": "^2.5.0",
"@lerna-lite/publish": "^2.5.0",
"@lerna-lite/run": "^2.5.0",
"rome": "^12.1.3",
"@biomejs/biome": "^1.2.2",
"@lerna-lite/cli": "^2.5.1",
"@lerna-lite/publish": "^2.5.1",
"@lerna-lite/run": "^2.5.1",
"tslib": "^2.6.2",
"typescript": "^5.2.2"
}
Expand Down
8 changes: 4 additions & 4 deletions packages/anzen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
},
"scripts": {
"build": "rm -rf dist && tsc --build ./tsconfig_esm.json && tsc --project ./tsconfig_cjs.json",
"check": "rome check src --apply-unsafe",
"format": "rome format src --write",
"check": "biome check src --apply-unsafe",
"format": "biome format src --write",
"prepublishOnly": "pnpm run test && pnpm run build",
"tdd": "tsc-watch --build ./tsconfig.json --onSuccess \"node --test --test-reporter spec dist/esm/__tests__/*.js\"",
"test": "tsc --build ./tsconfig.json && node --test --test-reporter spec dist/esm/__tests__/*.js"
Expand Down Expand Up @@ -49,8 +49,8 @@
},
"types": "dist/types/anzen.d.ts",
"devDependencies": {
"@types/node": "^18.17.14",
"rome": "^12.1.3",
"@biomejs/biome": "^1.2.2",
"@types/node": "^18.17.17",
"tsc-watch": "^6.0.4",
"typescript": "^5.2.2"
}
Expand Down
1 change: 1 addition & 0 deletions packages/anzen/src/anzen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ async function handleResult(
return response.getValue();
}

// biome-ignore lint/complexity/noStaticOnlyClass: <explanation>
export class Result {
static success<T>(value: T) {
return new ResultSuccess<T>(value);
Expand Down
8 changes: 4 additions & 4 deletions packages/ayamari/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
},
"scripts": {
"build": "rm -rf dist && tsc --build ./tsconfig_esm.json && tsc --project ./tsconfig_cjs.json",
"check": "rome check src --apply-unsafe",
"format": "rome format src --write",
"check": "biome check src --apply-unsafe",
"format": "biome format src --write",
"prepublishOnly": "pnpm run test && pnpm run build",
"tdd": "tsc-watch --build ./tsconfig.json --onSuccess \"node --test --test-reporter spec dist/esm/__tests__/*.js\"",
"test": "tsc --build ./tsconfig.json && node --test --test-reporter spec dist/esm/__tests__/*.js"
Expand Down Expand Up @@ -57,8 +57,8 @@
"@daisugi/anzen": "workspace:*"
},
"devDependencies": {
"@types/node": "^18.17.14",
"rome": "^12.1.3",
"@biomejs/biome": "^1.2.2",
"@types/node": "^18.17.17",
"tsc-watch": "^6.0.4",
"typescript": "^5.2.2"
}
Expand Down
1 change: 1 addition & 0 deletions packages/ayamari/src/pretty_stack.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AyamariErr } from './ayamari.js';

// biome-ignore lint/complexity/noStaticOnlyClass: <explanation>
export class PrettyStack {
/** Kindly borrowed from https://github.com/errwischt/stacktrace-parser/blob/master/src/stack-trace-parser.js */
static #lineRe =
Expand Down
8 changes: 4 additions & 4 deletions packages/daisugi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
},
"scripts": {
"build": "rm -rf dist && tsc --build ./tsconfig_esm.json && tsc --project ./tsconfig_cjs.json",
"check": "rome check src --apply-unsafe",
"format": "rome format src --write",
"check": "biome check src --apply-unsafe",
"format": "biome format src --write",
"prepublishOnly": "pnpm run test && pnpm run build",
"tdd": "tsc-watch --build ./tsconfig.json --onSuccess \"node --test --test-reporter spec dist/esm/__tests__/*.js\"",
"test": "tsc --build ./tsconfig.json && node --test --test-reporter spec dist/esm/__tests__/*.js"
Expand Down Expand Up @@ -52,8 +52,8 @@
"@daisugi/ayamari": "workspace:*"
},
"devDependencies": {
"@types/node": "^18.17.14",
"rome": "^12.1.3",
"@biomejs/biome": "^1.2.2",
"@types/node": "^18.17.17",
"tsc-watch": "^6.0.4",
"typescript": "^5.2.2"
}
Expand Down
8 changes: 4 additions & 4 deletions packages/kado/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
},
"scripts": {
"build": "rm -rf dist && tsc --build ./tsconfig_esm.json && tsc --project ./tsconfig_cjs.json",
"check": "rome check src --apply-unsafe",
"format": "rome format src --write",
"check": "biome check src --apply-unsafe",
"format": "biome format src --write",
"prepublishOnly": "pnpm run test && pnpm run build",
"tdd": "tsc-watch --build ./tsconfig.json --onSuccess \"node --test --test-reporter spec dist/esm/__tests__/*.js\"",
"test": "tsc --build ./tsconfig.json && node --test --test-reporter spec dist/esm/__tests__/*.js"
Expand Down Expand Up @@ -55,8 +55,8 @@
"@daisugi/kintsugi": "workspace:*"
},
"devDependencies": {
"@types/node": "^18.17.14",
"rome": "^12.1.3",
"@biomejs/biome": "^1.2.2",
"@types/node": "^18.17.17",
"tsc-watch": "^6.0.4",
"typescript": "^5.2.2"
}
Expand Down
72 changes: 52 additions & 20 deletions packages/kado/src/__tests__/kado_test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Ayamari, type AyamariErr } from '@daisugi/ayamari';
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { Ayamari, type AyamariErr } from '@daisugi/ayamari';

import { Kado, type KadoContainer, type KadoManifestItem } from '../kado.js';
import {
Kado,
type KadoContainer,
type KadoManifestItem,
} from '../kado.js';

describe('Kado', () => {
it('should have proper api', () => {
Expand All @@ -13,8 +17,14 @@ describe('Kado', () => {

const { container } = new Kado();

assert.strictEqual(typeof container.resolve, 'function');
assert.strictEqual(typeof container.register, 'function');
assert.strictEqual(
typeof container.resolve,
'function',
);
assert.strictEqual(
typeof container.register,
'function',
);
assert.strictEqual(typeof container.list, 'function');
assert.strictEqual(typeof container.get, 'function');
});
Expand Down Expand Up @@ -90,11 +100,11 @@ describe('Kado', () => {
it('useClass Transient', async () => {
const { container } = new Kado();

class A {
constructor() {}
}
class A {}

container.register([{ token: 'A', useClass: A, scope: 'Transient' }]);
container.register([
{ token: 'A', useClass: A, scope: 'Transient' },
]);

const a = await container.resolve<A>('A');
const anotherA = await container.resolve<A>('A');
Expand Down Expand Up @@ -177,7 +187,9 @@ describe('Kado', () => {

container.register(manifestItems);

const a = await container.resolve<KadoManifestItem[]>('A');
const a = await container.resolve<KadoManifestItem[]>(
'A',
);

assert.deepEqual(a, manifestItems);
});
Expand Down Expand Up @@ -291,7 +303,9 @@ describe('Kado', () => {

const list = container.list();

assert.deepStrictEqual(list, [{ token: 'a', useValue: 'text' }]);
assert.deepStrictEqual(list, [
{ token: 'a', useValue: 'text' },
]);
});

it('#list() with symbol keys', () => {
Expand All @@ -301,7 +315,9 @@ describe('Kado', () => {

const list = container.list();

assert.deepStrictEqual(list, [{ token, useValue: 'text' }]);
assert.deepStrictEqual(list, [
{ token, useValue: 'text' },
]);
});

describe('when you try to resolve unregistered token', () => {
Expand All @@ -315,8 +331,14 @@ describe('Kado', () => {
(err as AyamariErr).message,
'Attempted to resolve unregistered dependency token: "a".',
);
assert.strictEqual((err as AyamariErr).code, Ayamari.errCode.NotFound);
assert.strictEqual((err as AyamariErr).name, 'NotFound [404]');
assert.strictEqual(
(err as AyamariErr).code,
Ayamari.errCode.NotFound,
);
assert.strictEqual(
(err as AyamariErr).name,
'NotFound [404]',
);
}
});
});
Expand All @@ -325,7 +347,9 @@ describe('Kado', () => {
it('should throw an err', async () => {
const { container } = new Kado();

container.register([{ token: 'a', useFn() {}, params: ['b'] }]);
container.register([
{ token: 'a', useFn() {}, params: ['b'] },
]);

try {
await container.resolve('a');
Expand All @@ -334,8 +358,14 @@ describe('Kado', () => {
(err as AyamariErr).message,
'Attempted to resolve unregistered dependency token: "b".',
);
assert.strictEqual((err as AyamariErr).code, Ayamari.errCode.NotFound);
assert.strictEqual((err as AyamariErr).name, 'NotFound [404]');
assert.strictEqual(
(err as AyamariErr).code,
Ayamari.errCode.NotFound,
);
assert.strictEqual(
(err as AyamariErr).name,
'NotFound [404]',
);
}
});
});
Expand Down Expand Up @@ -389,12 +419,14 @@ describe('Kado', () => {
constructor(public b: B) {}
}

class B {
constructor() {}
}
class B {}

class A {
constructor(public b: B, public b2: B, public c: C) {}
constructor(
public b: B,
public b2: B,
public c: C,
) {}
}

container.register([
Expand Down
8 changes: 4 additions & 4 deletions packages/kintsugi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
},
"scripts": {
"build": "rm -rf dist && tsc --build ./tsconfig_esm.json && tsc --project ./tsconfig_cjs.json",
"check": "rome check src --apply-unsafe",
"format": "rome format src --write",
"check": "biome check src --apply-unsafe",
"format": "biome format src --write",
"prepublishOnly": "pnpm run test && pnpm run build",
"tdd": "tsc-watch --build ./tsconfig.json --onSuccess \"node --test --test-reporter spec dist/esm/__tests__/*.js\"",
"test": "tsc --build ./tsconfig.json && node --test --test-reporter spec dist/esm/__tests__/*.js"
Expand Down Expand Up @@ -55,8 +55,8 @@
"@daisugi/ayamari": "workspace:*"
},
"devDependencies": {
"@types/node": "^18.17.14",
"rome": "^12.1.3",
"@biomejs/biome": "^1.2.2",
"@types/node": "^18.17.17",
"ts-mockito": "^2.6.1",
"tsc-watch": "^6.0.4",
"typescript": "^5.2.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/kintsugi/src/__tests__/with_cache_test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Result, type ResultSuccess } from '@daisugi/anzen';
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { Result, type ResultSuccess } from '@daisugi/anzen';
import { between, spy } from 'ts-mockito';

import { SimpleMemoryStore } from '../simple_memory_store.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/kintsugi/src/enc_to_fnv1a.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

const OFFSET_BASIS_32 = 2166136261;

function fnv1aString(string: String) {
function fnv1aString(string: string) {
let hash = OFFSET_BASIS_32;
for (let i = 0; i < string.length; i++) {
hash ^= string.charCodeAt(i);
Expand Down
2 changes: 1 addition & 1 deletion packages/kintsugi/src/with_circuit_breaker.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { setInterval } from 'node:timers';
import {
type AnzenAnyResult,
type AnzenResultFn,
Result,
} from '@daisugi/anzen';
import { Ayamari } from '@daisugi/ayamari';
import { setInterval } from 'node:timers';

const { errFn, errCode } = new Ayamari();

Expand Down
8 changes: 4 additions & 4 deletions packages/land/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
},
"scripts": {
"build": "rm -rf dist && tsc --build ./tsconfig_esm.json && tsc --project ./tsconfig_cjs.json",
"check": "rome check src --apply-unsafe",
"format": "rome format src --write",
"check": "biome check src --apply-unsafe",
"format": "biome format src --write",
"prepublishOnly": "pnpm run test && pnpm run build",
"tdd": "tsc-watch --build ./tsconfig.json --onSuccess \"node --test --test-reporter spec dist/esm/__tests__/*.js\"",
"test": "tsc --build ./tsconfig.json && node --test --test-reporter spec dist/esm/__tests__/*.js"
Expand Down Expand Up @@ -63,8 +63,8 @@
"@daisugi/nekobasu": "workspace:*"
},
"devDependencies": {
"@types/node": "^18.17.14",
"rome": "^12.1.3",
"@biomejs/biome": "^1.2.2",
"@types/node": "^18.17.17",
"tsc-watch": "^6.0.4",
"typescript": "^5.2.2"
}
Expand Down
Loading

0 comments on commit 8a00c06

Please sign in to comment.