Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from Prettier and ESLint to Biome #80

Merged
merged 6 commits into from
Dec 9, 2024
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
23 changes: 0 additions & 23 deletions .eslintrc.json

This file was deleted.

14 changes: 14 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: lint
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: "package.json"
cache: "pnpm"
- run: pnpm install
- run: pnpm run ci
10 changes: 0 additions & 10 deletions .prettierrc

This file was deleted.

54 changes: 54 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true,
"defaultBranch": "master"
},
"files": {
"ignore": [
"docs/src/content/snippets/*.ts",
"docs/src/**/*.astro",
"examples/*/public/*.js"
],
"ignoreUnknown": false
},
"formatter": {
"enabled": true,
"indentStyle": "tab",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 80,
"bracketSpacing": true
},
"organizeImports": { "enabled": true },
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
"noUnusedVariables": "warn"
},
"complexity": {
"useLiteralKeys": "off"
},
"suspicious": {
"noEmptyBlockStatements": "error"
},
"style": {
"useTemplate": "off"
}
}
},
"javascript": {
"formatter": {
"quoteProperties": "asNeeded",
"trailingCommas": "es5",
"semicolons": "always",
"arrowParentheses": "always",
"quoteStyle": "double",
"bracketSpacing": false
}
}
}
2 changes: 1 addition & 1 deletion docs/astro.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {defineConfig} from "astro/config";
import starlight from "@astrojs/starlight";
import {defineConfig} from "astro/config";

export default defineConfig({
site: "https://matthewwid.github.io",
Expand Down
2 changes: 1 addition & 1 deletion docs/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/// <reference path="../.astro/types.d.ts" />
/// <reference path="../.astro/types.d.ts" />
8 changes: 5 additions & 3 deletions examples/benchmarks/benchmark.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {suite as suiteChannelPushManySessions} from "./suites/channel-push-many-sessions";

Promise.all([suiteChannelPushManySessions.setup()]).then((suites) =>
suites.forEach((suite) => suite.run())
);
Promise.all([suiteChannelPushManySessions.setup()]).then((suites) => {
for (const suite of suites) {
suite.run();
}
});
4 changes: 3 additions & 1 deletion examples/benchmarks/lib/createClientPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const createClientPool = async ({
await Promise.all(listeners);

return () => {
sources.forEach((eventsource) => eventsource.close());
for (const eventsource of sources) {
eventsource.close();
}
};
};
7 changes: 5 additions & 2 deletions examples/benchmarks/suites/Suite.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Suite as BenchmarkSuite} from "benchmark";
import express, {Express} from "express";
import express, {type Express} from "express";

/**
* Wrap the Benchmark.js Suite with a much nicer and more
Expand All @@ -8,7 +8,10 @@ import express, {Express} from "express";
export class Suite extends BenchmarkSuite {
static port = 8000;

constructor(name: string, private createBenchmarks: () => Promise<void>) {
constructor(
name: string,
private createBenchmarks: () => Promise<void>
) {
super(name, {async: true});

this.on("start", () => {
Expand Down
6 changes: 3 additions & 3 deletions examples/benchmarks/suites/channel-push-many-sessions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */

import {createSession, createChannel} from "better-sse";
// @ts-ignore
import SseChannel from "sse-channel";
import {createChannel, createSession} from "better-sse";
// @ts-ignore
import EasySse from "easy-server-sent-events";
// @ts-ignore
import SseChannel from "sse-channel";
import {createClientPool} from "../lib/createClientPool";
import {Suite} from "./Suite";

Expand Down
4 changes: 2 additions & 2 deletions examples/channels/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path";
import express from "express";
import path from "node:path";
import {createSession} from "better-sse";
import express from "express";
import {ticker} from "./channels/ticker";

const app = express();
Expand Down
4 changes: 2 additions & 2 deletions examples/getting-started/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path";
import path from "node:path";
import {type Session, createSession} from "better-sse";
import express from "express";
import {createSession, Session} from "better-sse";

const app = express();

Expand Down
12 changes: 6 additions & 6 deletions examples/http2/server.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {resolve} from "path";
import {promisify} from "util";
import {createSecureServer} from "http2";
import {createSecureServer} from "node:http2";
import {resolve} from "node:path";
import {promisify} from "node:util";
import {createSession} from "better-sse";
import {
CertificateCreationOptions,
CertificateCreationResult,
type CertificateCreationOptions,
type CertificateCreationResult,
createCertificate as createCertificateCallback,
} from "pem";
import {createSession} from "better-sse";

(async () => {
const createCertificate = promisify<
Expand Down
24 changes: 15 additions & 9 deletions examples/resource-monitor/channels/resource.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import osu, {NetStatMetrics} from "node-os-utils";
import {createChannel} from "better-sse";
import osu, {type NetStatMetrics} from "node-os-utils";

const resource = createChannel();

Expand All @@ -11,10 +11,13 @@ const broadcastSystemStats = async () => {
const {totalMemMb, freeMemMb} = await osu.mem.info();
const memoryUsage = (freeMemMb / totalMemMb) * 100;

resource.broadcast({
cpuUsage,
memoryUsage,
}, "system-stats");
resource.broadcast(
{
cpuUsage,
memoryUsage,
},
"system-stats"
);

setTimeout(broadcastSystemStats, interval);
};
Expand All @@ -27,10 +30,13 @@ const broadcastNetStats = async () => {
total: {inputMb, outputMb},
} = netStats as NetStatMetrics;

resource.broadcast({
inputMb,
outputMb,
}, "net-stats");
resource.broadcast(
{
inputMb,
outputMb,
},
"net-stats"
);

setTimeout(broadcastNetStats, interval);
};
Expand Down
4 changes: 2 additions & 2 deletions examples/resource-monitor/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path";
import express from "express";
import path from "node:path";
import {createSession} from "better-sse";
import express from "express";
import {resource} from "./channels/resource";

const app = express();
Expand Down
6 changes: 3 additions & 3 deletions examples/streams/server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from "path";
import express from "express";
import path from "node:path";
import {Readable} from "node:stream";
import {createSession} from "better-sse";
import {Readable} from "stream";
import express from "express";

const app = express();

Expand Down
19 changes: 6 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
"scripts": {
"build": "tsup",
"test": "vitest",
"format": "prettier --write ./src/**/*.ts",
"lint": "eslint \"./src/**/*.ts\"",
"prepublishOnly": "npm-run-all format test build"
"format": "biome check --linter-enabled=false --write",
"lint": "biome lint --write",
"ci": "biome ci",
"prepublishOnly": "npm-run-all ci build"
},
"main": "./build/index.js",
"module": "./build/index.mjs",
Expand All @@ -32,27 +33,19 @@
"import": "./build/index.mjs"
}
},
"files": [
"build",
"!build/**/*.map"
],
"files": ["build", "!build/**/*.map"],
"engines": {
"node": ">=20",
"pnpm": ">=9"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@tsconfig/node20": "^20.1.4",
"@types/eventsource": "^1.1.15",
"@types/express": "^5.0.0",
"@types/node": "^22.7.6",
"@typescript-eslint/eslint-plugin": "^8.9.0",
"@typescript-eslint/parser": "^8.9.0",
"eslint": "^8.57.1",
"eslint-plugin-tsdoc": "^0.3.0",
"eventsource": "^2.0.2",
"npm-run-all": "^4.1.5",
"prettier": "^3.3.3",
"ts-node": "^10.9.2",
"tsup": "^8.3.0",
"typescript": "^5.6.3",
"vitest": "^2.1.3"
Expand Down
Loading
Loading