Skip to content

chore: use Biome #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# style: format using Biome
f938a27bec6ed2dd565e6c421b08fc8e487276b8
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- run: corepack enable
- run: echo node `node --version`, pnpm v`pnpm --version`
- run: pnpm install --frozen-lockfile
- run: pnpm --color --recursive --parallel run lint
- run: pnpm --color run check
- run: pnpm --color --recursive run typecheck
- run: pnpm --color run test
# @info check if `createDefineTranslationsConfig`'s return type can be inferred
Expand Down
1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

6 changes: 1 addition & 5 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"recommendations": [
"Gruntfuggly.todo-tree",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
],
"recommendations": ["Gruntfuggly.todo-tree", "biomejs.biome"],
}
21 changes: 6 additions & 15 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,20 @@
"typescript.tsdk": "node_modules/typescript/lib",

"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never",
"quickfix.biome": "explicit",
"source.organizeImports.biome": "explicit",
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true,

"eslint.experimental.useFlatConfig": true,
"eslint.validate": [
"javascript",
"typescript",
"typescriptreact",
"json",
"jsonc",
],

"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.defaultFormatter": "biomejs.biome",
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.defaultFormatter": "biomejs.biome",
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.defaultFormatter": "biomejs.biome",
},

"typescript.preferences.importModuleSpecifier": "non-relative",
Expand Down
38 changes: 38 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"defaultBranch": "trunk",
"useIgnoreFile": true
},
"organizeImports": {
"enabled": true
},
"formatter": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "off"
}
}
},
"overrides": [
{
"include": [".vscode/*.json", "tsconfig.json", "tsconfig.*.json"],
"json": {
"parser": {
"allowComments": true,
"allowTrailingCommas": true
},
"formatter": {
"trailingCommas": "all"
}
}
}
]
}
75 changes: 0 additions & 75 deletions eslint.config.js

This file was deleted.

37 changes: 17 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
{
"type": "module",
"packageManager": "[email protected]+sha256.28ca61ece5a496148b73fabc9afb820f9c3fec4f55f04ce45a2cea0a5219f2e1",
"scripts": {
"test": "vitest",
"prepare-packages": "node --no-warnings scripts/prepare-packages.js"
},
"devDependencies": {
"@antfu/eslint-config": "^2.4.5",
"@testing-library/react": "^14.1.2",
"@types/node": "^20.10.4",
"@vitest/coverage-v8": "^1.0.4",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-perfectionist": "^2.5.0",
"happy-dom": "^12.10.3",
"prettier": "^3.1.1",
"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"
}
}
2 changes: 0 additions & 2 deletions packages/t-react/.prettierignore

This file was deleted.

82 changes: 40 additions & 42 deletions packages/t-react/package.json
Original file line number Diff line number Diff line change
@@ -1,44 +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",
"prelint": "prettier --check .",
"lint": "eslint .",
"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"
}
}
6 changes: 0 additions & 6 deletions packages/t-react/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ The React adapter has two peer dependencies which you need to install: the first

## Usage

<!-- eslint-skip -->

```ts
// translations.ts
import { defineTranslationsConfig } from "@wluwd/t-react";
Expand All @@ -42,8 +40,6 @@ export const {
);
```

<!-- eslint-skip -->

```tsx
// article/published-by.tsx
import { useTranslations, t } from "../translations.ts";
Expand Down Expand Up @@ -101,8 +97,6 @@ When this is set to `true`, initiates the translator in _lazy mode_.

Alongside the other functions and hooks, `defineTranslationsConfig` will return an `init` function with the following signature:

<!-- eslint-skip -->

```ts
type Init = (negotiators?: LocaleNegotiators<Locale>) => void;
```
Expand Down
5 changes: 2 additions & 3 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 All @@ -28,7 +30,6 @@ export const defineTranslationsConfig = createDefineTranslationsConfig(false, {
(loader, resources) => async (prefix) => {
const locale = defaultStore.get($locale);

// eslint-disable-next-line ts/no-unsafe-return
return delve(await loader(locale, resources), prefix);
},
],
Expand All @@ -44,9 +45,7 @@ export const defineTranslationsConfig = createDefineTranslationsConfig(false, {
return (prefix) => {
const translations = useAtomValue($translations);

// eslint-disable-next-line ts/no-unsafe-return
return useMemo(
// eslint-disable-next-line ts/no-unsafe-return
() => delve(translations, prefix),
[prefix, translations],
);
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
2 changes: 0 additions & 2 deletions packages/t-utils/.prettierignore

This file was deleted.

Loading
Loading