Skip to content

Commit 20a993d

Browse files
authored
Merge pull request #397 from prezly/feature/dev-21712-use-biome-in-sdk
[DEV-21712] Chore - Biome
2 parents d80008a + f2e1a22 commit 20a993d

File tree

11 files changed

+28
-78
lines changed

11 files changed

+28
-78
lines changed

.eslintrc.cjs

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

.github/workflows/check.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [push]
44

55
jobs:
66
build:
7-
name: Build, Test & Prettier
7+
name: Lint, Build & Test
88

99
runs-on: ubuntu-latest
1010

@@ -46,6 +46,3 @@ jobs:
4646

4747
- name: test
4848
run: npm test
49-
50-
- name: prettier
51-
run: npm run prettier:check

.prettierrc

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

biome.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.2.4/schema.json",
3+
"extends": ["@prezly/biome-config"],
4+
"files": {
5+
"includes": ["src/**"]
6+
},
7+
"linter": {
8+
"rules": {
9+
"suspicious": {
10+
"noShadowRestrictedNames": "off"
11+
}
12+
}
13+
}
14+
}

package.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,13 @@
3636
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
3737
"@babel/preset-env": "^7.7.1",
3838
"@babel/preset-typescript": "^7.18.6",
39+
"@biomejs/biome": "^2.2.4",
40+
"@prezly/biome-config": "^1.0.1",
3941
"@types/node": "^20.10.4",
40-
"@typescript-eslint/eslint-plugin": "^6.13.2",
41-
"@typescript-eslint/parser": "^6.13.2",
4242
"babel-plugin-add-import-extension": "^1.6.0",
4343
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
4444
"cross-env": "^7.0.3",
45-
"eslint": "^8.56.0",
46-
"eslint-config-prettier": "^8.10.0",
47-
"eslint-plugin-import": "^2.29.1",
4845
"np": "^9.2.0",
49-
"prettier": "^2.8.8",
5046
"rimraf": "^3.0.0",
5147
"typescript": "^5.3.3",
5248
"vitest": "^1.2.2",
@@ -61,13 +57,13 @@
6157
"build:cjs": "babel ./src --ignore='**/*.test.ts' --config-file=./babel.config.cjs.json --extensions=.ts,.cts --source-root=./src --out-dir=./dist --out-file-extension .cjs",
6258
"watch": "tsc --watch --preserveWatchOutput --project .",
6359
"start": "npm run build --incremental --watch",
64-
"lint": "eslint ./src --ext=.ts",
65-
"lint:fix": "npm run lint -- --fix",
60+
"lint": "biome ci",
61+
"lint:fix": "biome lint --write",
6662
"test": "npm run test:build && npm run test:unit",
6763
"test:unit": "vitest run",
6864
"test:build": "node dist/index.js && tsc --noEmit dist/index.d.ts",
69-
"prettier:check": "prettier --check './src/**/*.{ts,js}'",
70-
"prettier:fix": "prettier --write './src/**/*.{ts,js}'",
65+
"format:check": "biome format",
66+
"format": "biome format --write",
7167
"prerelease": "npm run build",
7268
"release": "np"
7369
},

src/Client.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { readFileSync } from 'fs';
1+
import { readFileSync } from 'node:fs';
22
import { vi, beforeEach, describe, expect, it, afterEach } from 'vitest';
33
import type { MockResponseInitFunction } from 'vitest-fetch-mock';
44
import createFetchMock from 'vitest-fetch-mock';

src/api/DeferredJobsApiClient.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ function handleDeferredJob<V = any, P = any>(
4848
update(state.progress, state.value);
4949

5050
await sleep(JOB_STATUS_POLLING_INTERVAL);
51-
} while (true); // eslint-disable-line no-constant-condition
51+
// biome-ignore lint/correctness/noConstantCondition: <This infinite loop is expected and safe. There are two return statements breaking it when needed>
52+
} while (true);
5253
}
5354

5455
resolve(response.payload);

src/http/createRequest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ export async function createRequest<P = any>(
8585
if (!response.ok) {
8686
// Try to parse the response as JSON, if it contains any error messages
8787
// from backend. If not, fake the error message.
88-
let responsePayload;
88+
let responsePayload: any;
8989
try {
9090
responsePayload = await response.json();
91-
} catch (error) {
91+
} catch {
9292
responsePayload = createFakeErrorPayload(response);
9393
}
9494

src/types/Category.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ type WithNonEmptyTranslation<T extends Category, LocaleCode extends Culture['cod
114114
function isNonEmpty(
115115
translation: Category.Translation | undefined,
116116
): translation is NonEmptyTranslation {
117-
return Boolean(translation && translation.name && translation.slug);
117+
return Boolean(translation?.name && translation.slug);
118118
}
119119

120120
function localeCode(locale: LocaleIdentifier): Culture['code'] {

src/types/SortOrder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function toString(arg: SortOrder | SortOrder.Column | SortOrder.Direction): stri
120120
return `${toString(arg.direction)}${arg.name}`;
121121
}
122122

123-
function validateColumnName(name: string): void | never {
123+
function validateColumnName(name: string): undefined | never {
124124
if (name.length === 0) {
125125
throw new Error(`Invalid sort column name: '${name}'.`);
126126
}

0 commit comments

Comments
 (0)