diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index 672320d0..00000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,52 +0,0 @@ -module.exports = { - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "prettier", - "eslint:recommended", - "plugin:@typescript-eslint/recommended" - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 12, - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint", - "import", - ], - "rules": { - "import/no-default-export": "error", - "import/no-extraneous-dependencies": "error", - "func-style": ["error", "declaration"], - "import/order": [ - "error", - { - "alphabetize": { - "order": "asc", - "caseInsensitive": true - }, - "groups": [["builtin", "external"], "internal", "parent", "sibling", "index"], - "newlines-between": "always" - } - ], - "@typescript-eslint/ban-ts-comment": "warn", - "@typescript-eslint/consistent-type-imports": "error", - "@typescript-eslint/no-empty-interface": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-namespace": "off", - "@typescript-eslint/no-unused-vars": "warn", - "@typescript-eslint/no-inferrable-types": "warn" - }, - "overrides": [ - { - "files": ["**/*.test.*"], - "rules": { - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-non-null-assertion": "off", - } - }, - ] -} diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 160184b8..93113067 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -4,7 +4,7 @@ on: [push] jobs: build: - name: Build, Test & Prettier + name: Lint, Build & Test runs-on: ubuntu-latest @@ -46,6 +46,3 @@ jobs: - name: test run: npm test - - - name: prettier - run: npm run prettier:check diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index a174dd40..00000000 --- a/.prettierrc +++ /dev/null @@ -1,5 +0,0 @@ -tabWidth: 4 -printWidth: 100 -singleQuote: true -arrowParens: always -trailingComma: all diff --git a/biome.json b/biome.json new file mode 100644 index 00000000..5822fc71 --- /dev/null +++ b/biome.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://biomejs.dev/schemas/2.2.4/schema.json", + "extends": ["@prezly/biome-config"], + "files": { + "includes": ["src/**"] + }, + "linter": { + "rules": { + "suspicious": { + "noShadowRestrictedNames": "off" + } + } + } +} diff --git a/package.json b/package.json index fd16dc3b..c1c394e4 100644 --- a/package.json +++ b/package.json @@ -36,17 +36,13 @@ "@babel/plugin-proposal-export-namespace-from": "^7.18.9", "@babel/preset-env": "^7.7.1", "@babel/preset-typescript": "^7.18.6", + "@biomejs/biome": "^2.2.4", + "@prezly/biome-config": "^1.0.1", "@types/node": "^20.10.4", - "@typescript-eslint/eslint-plugin": "^6.13.2", - "@typescript-eslint/parser": "^6.13.2", "babel-plugin-add-import-extension": "^1.6.0", "babel-plugin-transform-inline-environment-variables": "^0.4.4", "cross-env": "^7.0.3", - "eslint": "^8.56.0", - "eslint-config-prettier": "^8.10.0", - "eslint-plugin-import": "^2.29.1", "np": "^9.2.0", - "prettier": "^2.8.8", "rimraf": "^3.0.0", "typescript": "^5.3.3", "vitest": "^1.2.2", @@ -61,13 +57,13 @@ "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", "watch": "tsc --watch --preserveWatchOutput --project .", "start": "npm run build --incremental --watch", - "lint": "eslint ./src --ext=.ts", - "lint:fix": "npm run lint -- --fix", + "lint": "biome ci", + "lint:fix": "biome lint --write", "test": "npm run test:build && npm run test:unit", "test:unit": "vitest run", "test:build": "node dist/index.js && tsc --noEmit dist/index.d.ts", - "prettier:check": "prettier --check './src/**/*.{ts,js}'", - "prettier:fix": "prettier --write './src/**/*.{ts,js}'", + "format:check": "biome format", + "format": "biome format --write", "prerelease": "npm run build", "release": "np" }, diff --git a/src/Client.test.ts b/src/Client.test.ts index bbfec20e..5638970d 100644 --- a/src/Client.test.ts +++ b/src/Client.test.ts @@ -1,4 +1,4 @@ -import { readFileSync } from 'fs'; +import { readFileSync } from 'node:fs'; import { vi, beforeEach, describe, expect, it, afterEach } from 'vitest'; import type { MockResponseInitFunction } from 'vitest-fetch-mock'; import createFetchMock from 'vitest-fetch-mock'; diff --git a/src/api/DeferredJobsApiClient.ts b/src/api/DeferredJobsApiClient.ts index e1955bce..5e8a1537 100644 --- a/src/api/DeferredJobsApiClient.ts +++ b/src/api/DeferredJobsApiClient.ts @@ -48,7 +48,8 @@ function handleDeferredJob( update(state.progress, state.value); await sleep(JOB_STATUS_POLLING_INTERVAL); - } while (true); // eslint-disable-line no-constant-condition + // biome-ignore lint/correctness/noConstantCondition: + } while (true); } resolve(response.payload); diff --git a/src/http/createRequest.ts b/src/http/createRequest.ts index 18f751f8..f9c449d5 100644 --- a/src/http/createRequest.ts +++ b/src/http/createRequest.ts @@ -85,10 +85,10 @@ export async function createRequest

( if (!response.ok) { // Try to parse the response as JSON, if it contains any error messages // from backend. If not, fake the error message. - let responsePayload; + let responsePayload: any; try { responsePayload = await response.json(); - } catch (error) { + } catch { responsePayload = createFakeErrorPayload(response); } diff --git a/src/types/Category.ts b/src/types/Category.ts index bbfee4ba..06692b65 100644 --- a/src/types/Category.ts +++ b/src/types/Category.ts @@ -114,7 +114,7 @@ type WithNonEmptyTranslation