Skip to content

Commit

Permalink
style: format using Biome
Browse files Browse the repository at this point in the history
  • Loading branch information
macarie committed Jun 27, 2024
1 parent 4952bcf commit f938a27
Show file tree
Hide file tree
Showing 19 changed files with 145 additions and 146 deletions.
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"type": "module",
"packageManager": "[email protected]+sha256.28ca61ece5a496148b73fabc9afb820f9c3fec4f55f04ce45a2cea0a5219f2e1",
"scripts": {
"test": "vitest",
"prepare-packages": "node --no-warnings scripts/prepare-packages.js",
"check": "biome check"
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@testing-library/react": "^14.1.2",
"@types/node": "^20.10.4",
"@vitest/coverage-v8": "^1.0.4",
"happy-dom": "^12.10.3",
"tsup": "^8.0.1",
"typescript": "^5.3.3",
"vitest": "^1.0.4"
}
"type": "module",
"packageManager": "[email protected]+sha256.28ca61ece5a496148b73fabc9afb820f9c3fec4f55f04ce45a2cea0a5219f2e1",
"scripts": {
"test": "vitest",
"prepare-packages": "node --no-warnings scripts/prepare-packages.js",
"check": "biome check"
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@testing-library/react": "^14.1.2",
"@types/node": "^20.10.4",
"@vitest/coverage-v8": "^1.0.4",
"happy-dom": "^12.10.3",
"tsup": "^8.0.1",
"typescript": "^5.3.3",
"vitest": "^1.0.4"
}
}
80 changes: 40 additions & 40 deletions packages/t-react/package.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
{
"name": "@wluwd/t-react",
"type": "module",
"version": "0.0.2",
"description": "",
"author": "Raul Macarie <[email protected]>",
"license": "MIT",
"homepage": "https://github.com/wluwd/t",
"repository": {
"type": "git",
"url": "git+https://github.com/wluwd/t.git",
"directory": "packages/t-react"
},
"bugs": {
"url": "https://github.com/wluwd/t/issues"
},
"exports": {
".": {
"types": "./source/index.ts",
"import": "./source/index.ts"
}
},
"scripts": {
"build": "tsup",
"typecheck": "tsc"
},
"peerDependencies": {
"jotai": ">=2.0.0",
"react": ">=17.0.0"
},
"dependencies": {
"@wluwd/t": "workspace:*",
"@wluwd/t-utils": "workspace:*",
"dlv": "^1.1.3"
},
"devDependencies": {
"@types/dlv": "^1.1.4",
"@types/react": "^18.2.45",
"jotai": "^2.6.0",
"react": "^18.2.0"
}
"name": "@wluwd/t-react",
"type": "module",
"version": "0.0.2",
"description": "",
"author": "Raul Macarie <[email protected]>",
"license": "MIT",
"homepage": "https://github.com/wluwd/t",
"repository": {
"type": "git",
"url": "git+https://github.com/wluwd/t.git",
"directory": "packages/t-react"
},
"bugs": {
"url": "https://github.com/wluwd/t/issues"
},
"exports": {
".": {
"types": "./source/index.ts",
"import": "./source/index.ts"
}
},
"scripts": {
"build": "tsup",
"typecheck": "tsc"
},
"peerDependencies": {
"jotai": ">=2.0.0",
"react": ">=17.0.0"
},
"dependencies": {
"@wluwd/t": "workspace:*",
"@wluwd/t-utils": "workspace:*",
"dlv": "^1.1.3"
},
"devDependencies": {
"@types/dlv": "^1.1.4",
"@types/react": "^18.2.45",
"jotai": "^2.6.0",
"react": "^18.2.0"
}
}
2 changes: 2 additions & 0 deletions packages/t-react/source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ const defaultStore = getDefaultStore();

export const defineTranslationsConfig = createDefineTranslationsConfig(false, {
locale: {
// biome-ignore lint/style/noNonNullAssertion: the value should be set
fn: ["getLocale", () => () => defaultStore.get($locale)!],
// biome-ignore lint/style/noNonNullAssertion: the value should be set
hook: ["useLocale", () => () => useAtomValue($locale)!],
setter: [
"setLocale",
Expand Down
2 changes: 1 addition & 1 deletion packages/t-react/tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
formatter,
lazyTranslations,
} from "@wluwd/t-utils";
import { defineTranslationsConfig } from "~/index.ts";
import { Component } from "react";
import { describe, expect, it } from "vitest";
import { defineTranslationsConfig } from "~/index.ts";

import type { ReactNode } from "react";

Expand Down
2 changes: 1 addition & 1 deletion packages/t-react/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";

import defaultConfig from "../../vitest.config.ts";
import { defineConfig, mergeConfig } from "vitest/config";
import defaultConfig from "../../vitest.config.ts";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Expand Down
58 changes: 29 additions & 29 deletions packages/t-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"name": "@wluwd/t-utils",
"type": "module",
"version": "0.0.1",
"description": "",
"author": "Raul Macarie <[email protected]>",
"license": "MIT",
"homepage": "https://github.com/wluwd/t",
"repository": {
"type": "git",
"url": "git+https://github.com/wluwd/t.git",
"directory": "packages/t-utils"
},
"bugs": {
"url": "https://github.com/wluwd/t/issues"
},
"exports": {
".": {
"types": "./source/index.ts",
"import": "./source/index.ts"
}
},
"scripts": {
"build": "tsup",
"typecheck": "tsc"
},
"dependencies": {
"@fluent/langneg": "^0.7.0",
"type-fest": "^4.8.3"
}
"name": "@wluwd/t-utils",
"type": "module",
"version": "0.0.1",
"description": "",
"author": "Raul Macarie <[email protected]>",
"license": "MIT",
"homepage": "https://github.com/wluwd/t",
"repository": {
"type": "git",
"url": "git+https://github.com/wluwd/t.git",
"directory": "packages/t-utils"
},
"bugs": {
"url": "https://github.com/wluwd/t/issues"
},
"exports": {
".": {
"types": "./source/index.ts",
"import": "./source/index.ts"
}
},
"scripts": {
"build": "tsup",
"typecheck": "tsc"
},
"dependencies": {
"@fluent/langneg": "^0.7.0",
"type-fest": "^4.8.3"
}
}
2 changes: 1 addition & 1 deletion packages/t-utils/source/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class UnknownLocale extends Error {
export class NoLocaleSet extends Error {
constructor(options?: ErrorOptions) {
super(
`Attempted to access translations without a specified locale.\n\nThis error typically occurs due to one of the following reasons:\n\n1. The \`defaultLocale\` was unintentionally omitted.\n2. The \`defaultLocale\` was intentionally omitted, but \`setLocale\` was not called — either by mistake or due to a race condition.`,
"Attempted to access translations without a specified locale.\n\nThis error typically occurs due to one of the following reasons:\n\n1. The `defaultLocale` was unintentionally omitted.\n2. The `defaultLocale` was intentionally omitted, but `setLocale` was not called — either by mistake or due to a race condition.",
options,
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/t-utils/tests/error.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { expect, it } from "vitest";
import {
NoLocaleFound,
NoLocaleSet,
NoTranslationsSet,
UnknownLocale,
isLocaleError,
} from "~/error.ts";
import { expect, it } from "vitest";

it("`isLocaleError` recognized `NoLocaleFound`", async () => {
expect(
Expand Down
2 changes: 1 addition & 1 deletion packages/t-utils/tests/formatter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { formatter } from "~/formatter.ts";
import { expect, it } from "vitest";
import { formatter } from "~/formatter.ts";

it("swaps `{{placeholder}}` with the `placeholder` property provided", () => {
expect(formatter("{{placeholder}}", { placeholder: "string" })).toBe(
Expand Down
2 changes: 1 addition & 1 deletion packages/t-utils/tests/lazy-translations.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { lazyTranslations } from "~/lazy-translations.ts";
import { expect, it } from "vitest";
import { lazyTranslations } from "~/lazy-translations.ts";

const fakeDefaultImport = {
default: {
Expand Down
2 changes: 1 addition & 1 deletion packages/t-utils/tests/negotiator.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { browser } from "~/negotiator.ts";
import { expect, it } from "vitest";
import { browser } from "~/negotiator.ts";

it("`browser` returns expected locale from `navigator.languages`", async () => {
// @info statically set by happy-dom, should never fail
Expand Down
2 changes: 1 addition & 1 deletion packages/t-utils/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";

import defaultConfig from "../../vitest.config.ts";
import { defineConfig, mergeConfig } from "vitest/config";
import defaultConfig from "../../vitest.config.ts";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Expand Down
58 changes: 29 additions & 29 deletions packages/t/package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"name": "@wluwd/t",
"type": "module",
"version": "0.1.0",
"description": "",
"author": "Raul Macarie <[email protected]>",
"license": "MIT",
"homepage": "https://github.com/wluwd/t",
"repository": {
"type": "git",
"url": "git+https://github.com/wluwd/t.git",
"directory": "packages/t"
},
"bugs": {
"url": "https://github.com/wluwd/t/issues"
},
"exports": {
".": {
"types": "./source/index.ts",
"import": "./source/index.ts"
}
},
"scripts": {
"build": "tsup",
"typecheck": "tsc"
},
"dependencies": {
"@wluwd/t-utils": "workspace:*",
"type-fest": "^4.8.3"
}
"name": "@wluwd/t",
"type": "module",
"version": "0.1.0",
"description": "",
"author": "Raul Macarie <[email protected]>",
"license": "MIT",
"homepage": "https://github.com/wluwd/t",
"repository": {
"type": "git",
"url": "git+https://github.com/wluwd/t.git",
"directory": "packages/t"
},
"bugs": {
"url": "https://github.com/wluwd/t/issues"
},
"exports": {
".": {
"types": "./source/index.ts",
"import": "./source/index.ts"
}
},
"scripts": {
"build": "tsup",
"typecheck": "tsc"
},
"dependencies": {
"@wluwd/t-utils": "workspace:*",
"type-fest": "^4.8.3"
}
}
28 changes: 14 additions & 14 deletions packages/t/source/factory.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { isKeyof } from "./utils.ts";
import { NoLocaleFound, UnknownLocale } from "@wluwd/t-utils";
import { isKeyof } from "./utils.ts";

import type {
AnyFormatter,
ExtractTranslations,
FromNamedFactory,
NamedFactory,
PathsToBranches,
} from "./utils.ts";
import type {
AnyTranslations,
LazyLoader,
Expand All @@ -20,6 +13,13 @@ import type {
Simplify,
ValueOf,
} from "type-fest";
import type {
AnyFormatter,
ExtractTranslations,
FromNamedFactory,
NamedFactory,
PathsToBranches,
} from "./utils.ts";

export type TranslationsPicker<
SignalInterface extends boolean,
Expand Down Expand Up @@ -198,13 +198,13 @@ export const createDefineTranslationsConfig: CreateDefineTranslationsConfig =
initializedLocaleSetter(negotiatedLocale);

return;
} else {
throw new UnknownLocale({
availableLocales: Object.keys(translationLoaders),
desiredLocale: negotiatedLocale,
negotiator,
});
}

throw new UnknownLocale({
availableLocales: Object.keys(translationLoaders),
desiredLocale: negotiatedLocale,
negotiator,
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/t/tests/factory.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NoLocaleFound, UnknownLocale, formatter } from "@wluwd/t-utils";
import { createDefineTranslationsConfig } from "~/factory.ts";
import { describe, expect, it, vi } from "vitest";
import { createDefineTranslationsConfig } from "~/factory.ts";

import type { Options } from "~/factory.ts";

Expand Down
2 changes: 1 addition & 1 deletion packages/t/tests/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, it } from "vitest";
import { createDefineTranslationsConfig } from "~/factory.ts";
import * as indexImports from "~/index.ts";
import { expect, it } from "vitest";

it("exports `t`, `createTranslationsFactory`, `lazyTranslations`, and the errors", () => {
expect(indexImports.createDefineTranslationsConfig).toBe(
Expand Down
2 changes: 1 addition & 1 deletion packages/t/tests/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isKeyof } from "~/utils.ts";
import { describe, expect, it } from "vitest";
import { isKeyof } from "~/utils.ts";

describe("`isKeyof`", () => {
it("should return `true` when `needle` is keyof `haystack`", () => {
Expand Down
Loading

0 comments on commit f938a27

Please sign in to comment.