Skip to content

Commit 51ebd17

Browse files
committed
chore: move to biome to align with parent project
1 parent 53b6c88 commit 51ebd17

Some content is hidden

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

47 files changed

+517
-1940
lines changed

.eslintrc

-56
This file was deleted.

.vscode/extensions.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["biomejs.biome"]
3+
}

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.defaultFormatter": "biomejs.biome"
3+
}

biome.json

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
3+
"linter": {
4+
"enabled": true,
5+
"rules": {
6+
"recommended": true,
7+
"correctness": {
8+
"noUnsafeOptionalChaining": "off",
9+
"useExhaustiveDependencies": "off",
10+
"noUnusedImports": "warn",
11+
"useJsxKeyInIterable": "off"
12+
},
13+
"complexity": {
14+
"noBannedTypes": "off",
15+
"noUselessConstructor": "off",
16+
"useOptionalChain": "warn",
17+
"noStaticOnlyClass": "off",
18+
"noForEach": "off"
19+
},
20+
"style": {
21+
"noNonNullAssertion": "off",
22+
"noInferrableTypes": "off",
23+
"noUnusedTemplateLiteral": "off",
24+
"useSingleVarDeclarator": "off",
25+
"noUselessElse": "off",
26+
"useNodejsImportProtocol": "off"
27+
},
28+
"suspicious": {
29+
"noExplicitAny": "off",
30+
"noExtraNonNullAssertion": "off",
31+
"noRedeclare": "off",
32+
"noPrototypeBuiltins": "off",
33+
"noConfusingVoidType": "off",
34+
"noArrayIndexKey": "off",
35+
"noThenProperty": "off",
36+
"noExportsInTest": "off"
37+
},
38+
"performance": {
39+
"noAccumulatingSpread": "off",
40+
"noDelete": "off"
41+
}
42+
},
43+
"ignore": [
44+
"node_modules",
45+
"jest.config.js",
46+
"dist",
47+
"build",
48+
"CHANGELOG.md",
49+
"package.json",
50+
"tsconfig.json"
51+
]
52+
},
53+
"organizeImports": {
54+
"enabled": true
55+
},
56+
"formatter": {
57+
"indentStyle": "space",
58+
"ignore": [
59+
"node_modules",
60+
"jest.config.js",
61+
"dist",
62+
"build",
63+
"CHANGELOG.md",
64+
"package.json",
65+
"tsconfig.json"
66+
],
67+
"indentWidth": 4
68+
},
69+
"javascript": {
70+
"formatter": {
71+
"semicolons": "always",
72+
"quoteStyle": "single",
73+
"jsxQuoteStyle": "single",
74+
"indentWidth": 4
75+
}
76+
},
77+
"json": {
78+
"formatter": {
79+
"indentWidth": 2
80+
}
81+
},
82+
"vcs": {
83+
"enabled": true,
84+
"defaultBranch": "main",
85+
"clientKind": "git"
86+
}
87+
}

example.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const app = createApp({
88
'demo-app:default.1d0fd3109556631d8e9469c75090f46f2ec269d094543890c9a81c4a',
99
clientKeys: ['proxy-secret', 'another-proxy-secret', 's1'],
1010
refreshInterval: 1000,
11-
logLevel: 'trace',
11+
//logLevel: 'trace',
1212
enableOAS: true,
1313
expServerSideSdkConfig: {
1414
tokens: ['server'],

package.json

+20-41
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
"scripts": {
88
"build": "tsc --pretty",
99
"example": "yarn run build && node example",
10-
"lint": "eslint ./src",
10+
"lint": "biome lint --write ./src",
1111
"test": "jest",
1212
"updateSnapshots": "jest -u",
1313
"prepare": "npm run build",
1414
"dev": "ENABLE_OAS=true ts-node-dev src/start.ts",
15-
"fmt": "prettier src --write --loglevel warn",
16-
"fmt:check": "prettier src --check"
15+
"fmt": "biome format --changed ./src --write",
16+
"fmt:check": "biome format --changed ./src",
17+
"biome:ci": "biome ci ./src"
1718
},
1819
"repository": {
1920
"type": "git",
@@ -41,54 +42,32 @@
4142
"@unleash/express-openapi": "^0.3.0",
4243
"compression": "^1.7.4",
4344
"cors": "^2.8.5",
44-
"express": "^4.18.2",
45-
"json-schema-to-ts": "^2.3.0",
46-
"openapi-types": "^11.0.0",
45+
"express": "^4.19.2",
46+
"json-schema-to-ts": "^3.1.0",
47+
"openapi-types": "^12.1.3",
4748
"prom-client": "^15.1.3",
48-
"qs": "^6.9.7",
49+
"qs": "^6.12.3",
4950
"type-is": "^1.6.18",
5051
"unleash-client": "^6.1.1"
5152
},
5253
"devDependencies": {
5354
"@apidevtools/swagger-parser": "10.1.0",
54-
"@babel/core": "^7.24.4",
55-
"@types/compression": "^1.7.2",
56-
"@types/cors": "^2.8.12",
57-
"@types/express": "^4.17.13",
55+
"@babel/core": "^7.25.2",
56+
"@biomejs/biome": "^1.8.3",
57+
"@types/compression": "^1.7.5",
58+
"@types/cors": "^2.8.17",
59+
"@types/express": "^4.17.21",
5860
"@types/jest": "^29.5.12",
59-
"@types/node": "18.7.14",
60-
"@types/supertest": "^2.0.12",
61-
"@types/type-is": "^1.6.3",
62-
"@typescript-eslint/eslint-plugin": "^5.22.0",
63-
"@typescript-eslint/parser": "^5.22.0",
64-
"babel-jest": "^28.0.3",
65-
"eslint": "^8.14.0",
66-
"eslint-config-airbnb-base": "^15.0.0",
67-
"eslint-config-airbnb-typescript": "^17.0.0",
68-
"eslint-config-prettier": "^8.5.0",
69-
"eslint-plugin-import": "^2.26.0",
70-
"eslint-plugin-prettier": "^4.0.0",
61+
"@types/node": "20.14.8",
62+
"@types/supertest": "^6.0.2",
63+
"@types/type-is": "^1.6.6",
64+
"babel-jest": "^29.7.0",
7165
"jest": "^29.7.0",
72-
"prettier": "^2.6.2",
73-
"semver": "^7.3.7",
74-
"supertest": "^6.2.3",
66+
"semver": "^7.6.3",
67+
"supertest": "^7.0.0",
7568
"ts-jest": "^29.2.4",
7669
"ts-node-dev": "^2.0.0",
77-
"typescript": "^4.6.4"
78-
},
79-
"prettier": {
80-
"proseWrap": "never",
81-
"singleQuote": true,
82-
"tabWidth": 4,
83-
"trailingComma": "all",
84-
"overrides": [
85-
{
86-
"files": "*.{json,yaml,yml,md}",
87-
"options": {
88-
"tabWidth": 2
89-
}
90-
}
91-
]
70+
"typescript": "^5.5.4"
9271
},
9372
"resolutions": {
9473
"wrap-ansi": "7.0.0",

src/app.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import compression from 'compression';
2-
import express, { Application } from 'express';
32
import cors from 'cors';
4-
import { IClient } from './client';
5-
import { createProxyConfig, IProxyOption } from './config';
3+
import express, { type Application } from 'express';
4+
import type { IClient } from './client';
5+
import { type IProxyOption, createProxyConfig } from './config';
66

7-
import UnleashProxy from './unleash-proxy';
8-
import { OpenApiService } from './openapi/openapi-service';
97
import requireContentType from './content-type-checker';
10-
import { createSingletonClient, createNewClient } from './create-client';
8+
import { createNewClient, createSingletonClient } from './create-client';
9+
import { OpenApiService } from './openapi/openapi-service';
10+
import UnleashProxy from './unleash-proxy';
1111

1212
export function createApp(
1313
options: IProxyOption,
@@ -48,6 +48,7 @@ export function createApp(
4848
const corsOptions = config.cors;
4949
app.use(cors(corsOptions));
5050

51+
// @ts-expect-error Express struggles with its types here, compression seems to be too old
5152
app.use(compression());
5253

5354
app.use(

src/client.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import EventEmitter from 'events';
2-
import { Context, Unleash, UnleashEvents, Variant } from 'unleash-client';
3-
import { FeatureInterface } from 'unleash-client/lib/feature';
4-
import Metrics from 'unleash-client/lib/metrics';
2+
import {
3+
type Context,
4+
type Unleash,
5+
UnleashEvents,
6+
type Variant,
7+
} from 'unleash-client';
8+
import type { FeatureInterface } from 'unleash-client/lib/feature';
9+
import type Metrics from 'unleash-client/lib/metrics';
510
import { getDefaultVariant } from 'unleash-client/lib/variant';
6-
import { IProxyConfig } from './config';
7-
import { Logger } from './logger';
11+
import type { IProxyConfig } from './config';
12+
import type { Logger } from './logger';
813
import { lastMetricsFetch, lastMetricsUpdate } from './prom-metrics';
914

1015
export type FeatureToggleStatus = {

src/config.ts

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
import { CorsOptions } from 'cors';
2-
import { Application } from 'express';
3-
import { ClientFeaturesResponse, Strategy, TagFilter } from 'unleash-client';
4-
import { BootstrapOptions } from 'unleash-client/lib/repository/bootstrap-provider';
5-
import { Logger, LogLevel, SimpleLogger } from './logger';
1+
import type { CorsOptions } from 'cors';
2+
import type { Application } from 'express';
3+
import type {
4+
ClientFeaturesResponse,
5+
Strategy,
6+
TagFilter,
7+
} from 'unleash-client';
8+
import type { HttpOptions } from 'unleash-client/lib/http-options';
9+
import type { BootstrapOptions } from 'unleash-client/lib/repository/bootstrap-provider';
10+
import type { StorageProvider } from 'unleash-client/lib/repository/storage-provider';
11+
import type { ContextEnricher } from './enrich-context';
12+
import { type LogLevel, type Logger, SimpleLogger } from './logger';
613
import { generateInstanceId } from './util';
7-
import { HttpOptions } from 'unleash-client/lib/http-options';
8-
import { StorageProvider } from 'unleash-client/lib/repository/storage-provider';
9-
import { ContextEnricher } from './enrich-context';
1014

1115
export interface ServerSideSdkConfig {
1216
tokens: string[];
@@ -310,7 +314,7 @@ export function createProxyConfig(option: IProxyOption): IProxyConfig {
310314
process.env.UNLEASH_INSTANCE_ID ||
311315
generateInstanceId();
312316

313-
let proxyBasePath = sanitizeBasePath(
317+
const proxyBasePath = sanitizeBasePath(
314318
option.proxyBasePath || process.env.PROXY_BASE_PATH,
315319
);
316320
return {

src/content-type-checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RequestHandler } from 'express';
1+
import type { RequestHandler } from 'express';
22
import { hasBody, is } from 'type-is';
33

44
const DEFAULT_ACCEPTED_CONTENT_TYPE = 'application/json';

src/context-middleware.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { NextFunction, Request, Response } from 'express';
1+
import type { NextFunction, Request, Response } from 'express';
22
import { createContext } from './create-context';
3-
import { ContextEnricher, enrichContext } from './enrich-context';
3+
import { type ContextEnricher, enrichContext } from './enrich-context';
44

55
const POST = 'POST';
66
const GET = 'GET';

src/create-client.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { IProxyConfig } from './config';
2-
import Client from './client';
3-
import { initialize, Unleash } from 'unleash-client';
1+
import { Unleash, initialize } from 'unleash-client';
42
import Metrics from 'unleash-client/lib/metrics';
53
import { defaultStrategies } from 'unleash-client/lib/strategy';
4+
import Client from './client';
5+
import type { IProxyConfig } from './config';
66

77
export const createSingletonClient = (config: IProxyConfig): Client => {
88
const customHeadersFunction = async () => ({
@@ -23,7 +23,7 @@ export const createSingletonClient = (config: IProxyConfig): Client => {
2323
customHeadersFunction,
2424
bootstrap: config.bootstrap,
2525
storageProvider: config.storageProvider,
26-
...(!!config.httpOptions ? { httpOptions: config.httpOptions } : {}),
26+
...(config.httpOptions ? { httpOptions: config.httpOptions } : {}),
2727
});
2828

2929
const metrics = new Metrics({
@@ -35,7 +35,7 @@ export const createSingletonClient = (config: IProxyConfig): Client => {
3535
metricsJitter: config.metricsJitter,
3636
url: config.unleashUrl,
3737
customHeadersFunction,
38-
...(!!config.httpOptions ? { httpOptions: config.httpOptions } : {}),
38+
...(config.httpOptions ? { httpOptions: config.httpOptions } : {}),
3939
});
4040

4141
return new Client(config, unleash, metrics);
@@ -60,7 +60,7 @@ export const createNewClient = (config: IProxyConfig): Client => {
6060
customHeadersFunction,
6161
bootstrap: config.bootstrap,
6262
storageProvider: config.storageProvider,
63-
...(!!config.httpOptions ? { httpOptions: config.httpOptions } : {}),
63+
...(config.httpOptions ? { httpOptions: config.httpOptions } : {}),
6464
});
6565

6666
const metrics = new Metrics({
@@ -72,7 +72,7 @@ export const createNewClient = (config: IProxyConfig): Client => {
7272
metricsJitter: config.metricsJitter,
7373
url: config.unleashUrl,
7474
customHeadersFunction,
75-
...(!!config.httpOptions ? { httpOptions: config.httpOptions } : {}),
75+
...(config.httpOptions ? { httpOptions: config.httpOptions } : {}),
7676
});
7777

7878
return new Client(config, unleash, metrics);

0 commit comments

Comments
 (0)