Skip to content
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
52 changes: 0 additions & 52 deletions .eslintrc.cjs

This file was deleted.

5 changes: 1 addition & 4 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,45 @@

jobs:
build:
name: Build, Test & Prettier
name: Lint, Build & Test

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

env:
CI: true

steps:
- uses: actions/checkout@v4

- name: Cache node modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: "**/node_modules"
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: npm install
run: npm i

- name: lint
run: npm run lint

- name: build
run: npm run build

- name: test
run: npm test

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

- name: prettier
run: npm run prettier:check
5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

14 changes: 14 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
16 changes: 6 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Client.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 2 additions & 1 deletion src/api/DeferredJobsApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ function handleDeferredJob<V = any, P = any>(
update(state.progress, state.value);

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

resolve(response.payload);
Expand Down
4 changes: 2 additions & 2 deletions src/http/createRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ export async function createRequest<P = any>(
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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/types/Category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ type WithNonEmptyTranslation<T extends Category, LocaleCode extends Culture['cod
function isNonEmpty(
translation: Category.Translation | undefined,
): translation is NonEmptyTranslation {
return Boolean(translation && translation.name && translation.slug);
return Boolean(translation?.name && translation.slug);
}

function localeCode(locale: LocaleIdentifier): Culture['code'] {
Expand Down
2 changes: 1 addition & 1 deletion src/types/SortOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function toString(arg: SortOrder | SortOrder.Column | SortOrder.Direction): stri
return `${toString(arg.direction)}${arg.name}`;
}

function validateColumnName(name: string): void | never {
function validateColumnName(name: string): undefined | never {
if (name.length === 0) {
throw new Error(`Invalid sort column name: '${name}'.`);
}
Expand Down
1 change: 0 additions & 1 deletion src/types/Story.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { describe, expect, it } from 'vitest';

import type { Story, StoryRef } from './Story';
Expand Down