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
17 changes: 0 additions & 17 deletions .eslintrc

This file was deleted.

2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Global code owner - all files require review
* @sumolari
17 changes: 15 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ updates:
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'daily'
interval: 'weekly'
day: 'monday'
time: '05:00'
timezone: 'Europe/Madrid'
assignees:
- 'Sumolari'
- 'sumolari'
reviewers:
- 'sumolari'
open-pull-requests-limit: 0
commit-message:
prefix: 'chore'
prefix-development: 'chore'
include: 'scope'
labels:
- 'dependencies'
rebase-strategy: 'auto'
28 changes: 10 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ on:
- main

jobs:
build: # make sure build/ci work properly
build:
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- uses: actions/checkout@v2
- run: |
yarn --frozen-lockfile
- run: |
yarn build
test: # make sure the action works on a clean machine without building
- run: yarn --frozen-lockfile
- run: yarn build
test:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
Expand All @@ -28,18 +26,12 @@ jobs:
fetch-depth: 0
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Run linter
- name: Run linter and formatter
run: yarn lint
- name: Run check format
run: yarn format-check
- name: Run tests
run: yarn test --detectOpenHandles --forceExit
- name: Upload coverage
uses: caffco/code-climate-github-action@v0.0.1-alpha.5
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: yarn test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
repository_root_path: ${{github.workspace}}
collect_coverage: 'true'
coverage_file_patterns: |
coverage/lcov.info:lcov
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lint-staged
3 changes: 1 addition & 2 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"*.(ts)": ["eslint"],
"*": ["prettier --write"]
"*.ts": ["biome check --write --no-errors-on-unmatched"]
}
20 changes: 0 additions & 20 deletions .prettierrc

This file was deleted.

56 changes: 56 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"$schema": "https://biomejs.dev/schemas/2.1.2/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": true,
"includes": ["**/*.ts"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"style": "error",
"correctness": {
"recommended": true,
"noNodejsModules": "off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"semicolons": "always",
"trailingCommas": "all"
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
},
"overrides": [
{
"includes": ["vitest.config.ts"],
"linter": {
"rules": {
"style": {
"noDefaultExport": "off"
}
}
}
}
]
}
20 changes: 20 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
coverage:
status:
project:
default:
target: auto
threshold: 1%
base: auto
patch:
default:
target: auto
threshold: 1%
base: auto

comment:
layout: "reach,diff,flags,tree,reach"
behavior: default
require_changes: false

github_checks:
annotations: true
23 changes: 11 additions & 12 deletions example/server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import fs from 'fs';
import path from 'path';

import fs from 'node:fs';
import path from 'node:path';

Check warning on line 2 in example/server.ts

View check run for this annotation

Codecov / codecov/patch

example/server.ts#L1-L2

Added lines #L1 - L2 were not covered by tests
import Koa from 'koa';

import { IO } from '../src';
import { IO } from '../src/index.ts';

Check warning on line 5 in example/server.ts

View check run for this annotation

Codecov / codecov/patch

example/server.ts#L5

Added line #L5 was not covered by tests

const app = new Koa();
const io = new IO<
Expand All @@ -24,7 +23,7 @@
app.use(async (ctx, next) => {
const start = new Date();
await next();
const ms = new Date().getTime() - start.getTime();
const ms = Date.now() - start.getTime();

Check warning on line 26 in example/server.ts

View check run for this annotation

Codecov / codecov/patch

example/server.ts#L26

Added line #L26 was not covered by tests
console.log(`${ctx.method} ${ctx.url} - ${ms}ms`);
});

Expand All @@ -39,11 +38,11 @@
/**
* Socket middlewares
*/
io.use(async (ctx, next) => {
io.use(async (_ctx, next) => {

Check warning on line 41 in example/server.ts

View check run for this annotation

Codecov / codecov/patch

example/server.ts#L41

Added line #L41 was not covered by tests
console.log('Socket middleware');
const start = new Date().getTime();
const start = Date.now();

Check warning on line 43 in example/server.ts

View check run for this annotation

Codecov / codecov/patch

example/server.ts#L43

Added line #L43 was not covered by tests
await next();
const ms = new Date().getTime() - start;
const ms = Date.now() - start;

Check warning on line 45 in example/server.ts

View check run for this annotation

Codecov / codecov/patch

example/server.ts#L45

Added line #L45 was not covered by tests
console.log(`WS ${ms}ms`);
});

Expand Down Expand Up @@ -83,7 +82,7 @@
ctx.acknowledge('received');
});

io.on('numConnections', async (packet) => {
io.on('numConnections', async (_packet) => {

Check warning on line 85 in example/server.ts

View check run for this annotation

Codecov / codecov/patch

example/server.ts#L85

Added line #L85 was not covered by tests
console.log(`Number of connections: ${io.connections.size}`);
});

Expand All @@ -98,7 +97,7 @@
console.log('chat message received', ctx.data);

// Broadcasts to everybody, including this connection
((app as unknown) as { chat: typeof io }).chat.broadcast('message', 'yo connections, lets chat');
(app as unknown as { chat: typeof io }).chat.broadcast('message', 'yo connections, lets chat');

Check warning on line 100 in example/server.ts

View check run for this annotation

Codecov / codecov/patch

example/server.ts#L100

Added line #L100 was not covered by tests

// Broadcasts to all other connections
ctx.socket.broadcast.emit('message', 'ok connections:chat:broadcast');
Expand All @@ -109,9 +108,9 @@

chat.use(async (ctx, next) => {
ctx.teststring = 'chattest';
console.log(`ctx.socket =>`);
console.log('ctx.socket =>');

Check warning on line 111 in example/server.ts

View check run for this annotation

Codecov / codecov/patch

example/server.ts#L111

Added line #L111 was not covered by tests
console.dir(ctx.socket, { colors: true, depth: 2 });
console.log(`ctx.socket.nsp =>`, ctx.socket.nsp);
console.log('ctx.socket.nsp =>', ctx.socket.nsp);

Check warning on line 113 in example/server.ts

View check run for this annotation

Codecov / codecov/patch

example/server.ts#L113

Added line #L113 was not covered by tests
await next();
});

Expand Down
20 changes: 0 additions & 20 deletions jest.config.js

This file was deleted.

48 changes: 17 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
"build": "run-s build:clean build:tsc",
"build:clean": "rm -rf dist",
"build:tsc": "tsc",
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"lint": "eslint .",
"test": "jest $JEST_ARGS",
"prepublishOnly": "JEST_ARGS=--forceExit run-s format lint test build",
"example": "ts-node example/server"
"format": "biome format --write .",
"lint": "biome check .",
"test": "vitest run",
"test:watch": "vitest",
"prepublishOnly": "run-s format lint test build",
"example": "ts-node example/server",
"prepare": "husky"
},
"keywords": [
"koa",
Expand All @@ -38,42 +39,27 @@
"repository": "caffco/koa-socket.io",
"author": "Lluís Ulzurrun de Asanza i Sàez (Originally: Aaron Belovsky and Matt Styles)",
"license": "MIT",
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"dependencies": {
"socket.io": "^4.4.1",
"koa-compose": "^4.1.0"
"koa-compose": "^4.1.0",
"socket.io": "^4.4.1"
},
"devDependencies": {
"@biomejs/biome": "^2.1.2",
"@changesets/cli": "^2.13.0",
"@types/cookie": "^1.0.0",
"@types/cors": "^2.8.10",
"@types/jest": "^27.0.0",
"@types/koa": "^2.11.6",
"@types/koa-compose": "^3.2.5",
"@types/node": "^15.0.0",
"@types/socket.io": "^3.0.2",
"@types/socket.io-client": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^4.14.0",
"@typescript-eslint/parser": "^4.14.0",
"eslint": "^7.18.0",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"husky": "^4.3.8",
"jest": "^26.6.3",
"jest-circus": "^27.0.1",
"@types/node": "^24.1.0",
"@vitest/coverage-v8": "^3.2.4",
"@vitest/ui": "^3.2.4",
"husky": "^9.1.7",
"jsdom": "^26.1.0",
"koa": "^3.0.0",
"lint-staged": "^16.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.2.1",
"socket.io-client": "^4.0.0",
"ts-jest": "^26.4.4",
"ts-node": "^10.0.0",
"typescript": "^4.1.3"
"typescript": "^5.8.3",
"vitest": "^3.2.4"
}
}
Loading