Skip to content

Commit b8501ef

Browse files
authored
Sync alphalib 2025 08 27 (#247)
* import * biome cfg * w * Update package.json * Format * Update package.json * fixes * Update package.json * Update live-api.test.ts * Update live-api.test.ts * Update biome.json * Update biome.json * Fixes * w * Fix warnings 1 * Update live-api.test.ts * w * format * Update biome.json * Bioma * Update ci.yml * -eslint
1 parent e4b0571 commit b8501ef

File tree

122 files changed

+3066
-2772
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+3066
-2772
lines changed

.cursor/rules/coding-style.mdc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ description:
33
globs:
44
alwaysApply: true
55
---
6+
67
Coding style:
78

89
- Favor `async run() {` over `run = async () => {` inside ES6 classes
@@ -14,6 +15,6 @@ Coding style:
1415
- Do not wrap each function body and function call in `try`/`catch` blocks. It pollutes the code. Assume we will always have an e.g. `main().catch((err) => { console.error(err); process.exit(1) })` to catch us. I repeat: Avoid over-use of try-catch such as `try { // foo } catch (err) { console.error('error while foo'); throw err }`, assume we catch errors on a higher level and do not need the extra explananation.
1516
- Before creating new files and new code, see if we can leverage existing work, maybe slighty adapt that without breaking BC, to keep things DRY.
1617
- Favor early exits, so quickly `continue`, `return false` (or `throw` if needed), over nesting everything in positive conditions, creating christmas trees.
17-
- Use Prettier with 100 char line width, single quotes for JS/TS, semi: false
18+
- Use Biome with 100 char line width, single quotes for JS/TS, semi: false
1819
- Use descriptive names: PascalCase for components/types, camelCase for variables/methods/schemas
1920
- Alphabetize imports, group by source type (built-in/external/internal)

.eslintignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

.eslintrc.cjs

Lines changed: 0 additions & 52 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ on:
99
- '*'
1010

1111
jobs:
12-
eslint:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- uses: actions/checkout@v4
16-
- uses: actions/setup-node@v4
17-
with:
18-
node-version: 22
19-
- run: corepack yarn
20-
- run: corepack yarn lint:js
21-
2212
pack:
2313
runs-on: ubuntu-latest
2414
steps:
@@ -33,15 +23,15 @@ jobs:
3323
name: package
3424
path: '*.tgz'
3525

36-
prettier:
26+
biome:
3727
runs-on: ubuntu-latest
3828
steps:
3929
- uses: actions/checkout@v4
4030
- uses: actions/setup-node@v4
4131
with:
4232
node-version: 22
4333
- run: corepack yarn
44-
- run: corepack yarn lint:formatting
34+
- run: corepack yarn lint:js
4535

4636
typescript:
4737
runs-on: ubuntu-latest
@@ -96,9 +86,8 @@ jobs:
9686
release:
9787
runs-on: ubuntu-latest
9888
needs:
99-
- eslint
10089
- pack
101-
- prettier
90+
- biome
10291
- typescript
10392
- vitest
10493
if: startsWith(github.ref, 'refs/tags/')

.prettierignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.prettierrc.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
{
2-
"[javascript][typescript]": {
2+
"editor.codeActionsOnSave": {
3+
"source.fixAll.biome": "explicit",
4+
"source.fixAll.eslint": "explicit",
5+
"source.fixAll.stylelint": "explicit"
6+
},
7+
"editor.defaultFormatter": "biomejs.biome",
8+
"editor.formatOnSave": true,
9+
"eslint.format.enable": false,
10+
"[html]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
11+
"[javascript]": { "editor.defaultFormatter": "biomejs.biome" },
12+
"[javascriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
13+
"[json]": { "editor.defaultFormatter": "biomejs.biome" },
14+
"[liquid]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
15+
"[markdown]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
16+
"[typescript]": { "editor.defaultFormatter": "biomejs.biome" },
17+
"[typescriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
18+
"[yaml]": {
319
"editor.defaultFormatter": "esbenp.prettier-vscode"
420
}
521
}

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ yarn upgrade-interactive
2222

2323
## Linting
2424

25-
This project is linted using [ESLint](https://eslint.org). You can lint the project by running:
25+
This project is linted using Biome. You can lint the project by running:
2626

2727
```sh
2828
yarn lint:js
2929
```
3030

3131
## Formatting
3232

33-
This project is formatted using [Prettier](https://prettier.io). You can format the project:
33+
This project is formatted using Biome. You can format the project:
3434

3535
```sh
36-
yarn fix:formatting
36+
yarn fix:js
3737
```
3838

3939
## Testing

biome.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.2.2/schema.json",
3+
"files": {
4+
"includes": [
5+
"**",
6+
"!coverage",
7+
"!dist",
8+
"!node_modules",
9+
"!fixture",
10+
"!.vscode",
11+
"!src/alphalib"
12+
]
13+
},
14+
"formatter": {
15+
"enabled": true,
16+
"formatWithErrors": false,
17+
"indentStyle": "space",
18+
"indentWidth": 2,
19+
"lineEnding": "lf",
20+
"lineWidth": 100,
21+
"attributePosition": "auto"
22+
},
23+
"assist": { "actions": { "source": { "organizeImports": "on" } } },
24+
"linter": {
25+
"enabled": true,
26+
"rules": {
27+
"recommended": true,
28+
"suspicious": {
29+
"noExplicitAny": "warn",
30+
"noImplicitAnyLet": "error",
31+
"noConfusingVoidType": "warn",
32+
"noAssignInExpressions": "off",
33+
"noTemplateCurlyInString": "off"
34+
},
35+
"correctness": {
36+
"noInvalidUseBeforeDeclaration": "warn"
37+
},
38+
"complexity": {
39+
"useLiteralKeys": "off",
40+
"noForEach": "warn"
41+
},
42+
"style": {
43+
"noParameterAssign": "warn",
44+
"noUnusedTemplateLiteral": "off",
45+
"useAsConstAssertion": "error",
46+
"useDefaultParameterLast": "error",
47+
"useEnumInitializers": "error",
48+
"useSelfClosingElements": "error",
49+
"useSingleVarDeclarator": "error",
50+
"useNumberNamespace": "error",
51+
"noInferrableTypes": "error",
52+
"noUselessElse": "error"
53+
}
54+
}
55+
},
56+
"javascript": {
57+
"formatter": {
58+
"jsxQuoteStyle": "double",
59+
"quoteProperties": "asNeeded",
60+
"trailingCommas": "all",
61+
"semicolons": "asNeeded",
62+
"arrowParentheses": "always",
63+
"bracketSpacing": true,
64+
"bracketSameLine": false,
65+
"quoteStyle": "single",
66+
"attributePosition": "auto"
67+
}
68+
}
69+
}

examples/convert_to_webp.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
//
99
import { Transloadit } from 'transloadit'
1010

11+
const { TRANSLOADIT_KEY, TRANSLOADIT_SECRET } = process.env
12+
if (TRANSLOADIT_KEY == null || TRANSLOADIT_SECRET == null) {
13+
throw new Error('Please set TRANSLOADIT_KEY and TRANSLOADIT_SECRET')
14+
}
1115
const transloadit = new Transloadit({
12-
authKey: process.env.TRANSLOADIT_KEY!,
13-
authSecret: process.env.TRANSLOADIT_SECRET!,
16+
authKey: TRANSLOADIT_KEY,
17+
authSecret: TRANSLOADIT_SECRET,
1418
})
1519

1620
const filePath = process.argv[2]

0 commit comments

Comments
 (0)