Skip to content
Draft
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
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

30 changes: 0 additions & 30 deletions .eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ yarn-error.log*

.env
.direnv
/.eslintcache
51 changes: 51 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintConfigPrettier from "eslint-config-prettier";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";

export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.recommended,
eslintConfigPrettier,
eslintPluginPrettierRecommended,
{
files: ["**/*.js", "**/*.ts"],
plugins: {
'@typescript-eslint': tseslint.plugin,
},
languageOptions: {
parser: tseslint.parser,
parserOptions: {
'src': "./tsconfig.json",
'src-browser': "./tsconfig.json",
},
globals: {
window: true,
browser: true,
node: true,
},
},
rules: {
'prettier/prettier': 'error',
'import/prefer-default-export': 'off',
indent: 'off',
'implicit-arrow-linebreak': 'off', // conflicts with prettier
'no-unused-expressions': 'off', // breaks optional chaining
'@typescript-eslint/no-unused-expressions': 'error',
'max-len': ['error', { code: 120 }],
'@typescript-eslint/no-empty-function': 'off',
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-non-null-assertion': 'error',
'operator-linebreak': 'off',
'no-param-reassign': ['error', { props: false }],
'object-curly-newline': 'off',
},
ignores: [
"*.d.ts",
"api.js",
"webpack.config.js",
],
}
);
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['./src'],
Expand Down
40 changes: 21 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"files": [
"/dist"
],
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"lint": "eslint --ext .js,.ts src/ src.browser/",
"lint": "eslint --cache src/ src.browser/",
"build": "tsc",
"build:browser": "yarn clean && yarn build && parcel build src.browser/index.js -d dist.browser --out-file crosis.js",
"debug": "node debug/server.js",
Expand All @@ -21,29 +22,30 @@
"author": "[email protected]",
"license": "MIT",
"dependencies": {
"abortcontroller-polyfill": "1.7.5",
"engine.io-client": "3.5.4"
"abortcontroller-polyfill": "1.7.8",
"engine.io-client": "^6.6.3"
},
"devDependencies": {
"@replit/protocol": ">=0.3.16",
"@types/engine.io-client": "^3.1.8",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.7",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"eslint": "^8.15.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.0.0",
"express": "^4.19.2",
"@replit/protocol": ">=0.4.8",
"@types/engine.io-client": "^6.0.0",
"@types/jest": "^29.5.14",
"@types/node": "^22.13.4",
"@types/ws": "^8.5.14",
"@typescript-eslint/eslint-plugin": "^8.24.1",
"@typescript-eslint/parser": "^8.24.1",
"eslint": "^9.20.1",
"eslint-config-prettier": "10.0.1",
"eslint-plugin-prettier": "5.2.3",
"express": "^4.21.2",
"jest": "^29.7.0",
"jest-websocket-mock": "^2.5.0",
"mock-socket": "^9.3.1",
"prettier": "^2.6.2",
"ts-jest": "^29.1.5",
"typedoc": "^0.25.13",
"typescript": "^5.4.5",
"ws": "^8.17.1"
"prettier": "^3.5.1",
"ts-jest": "^29.2.5",
"typedoc": "^0.27.7",
"typescript": "^5.7.3",
"typescript-eslint": "^8.24.1",
"ws": "^8.18.0"
},
"peerDependencies": {
"@replit/protocol": ">=0.2.15"
Expand Down
1 change: 0 additions & 1 deletion src.browser/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line
import * as Crosis from '../dist';

window.Crosis = Crosis;
1 change: 0 additions & 1 deletion src/__tests__/redirect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { WebSocket } from 'mock-socket';
// eslint-disable-next-line
const genConnectionMetadata = require('../../debug/genConnectionMetadata');

// eslint-disable-next-line
jest.setTimeout(1000);

const testingClients: Array<Client<{ username: string }>> = [];
Expand Down
5 changes: 0 additions & 5 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1881,11 +1881,7 @@ export class Client<Ctx = null> {
try {
this.handleClose(ClientCloseReason.ErrorOrDestroy);
} catch (handleCloseErr) {
// We tried our best to clean up. But we need to keep going and report
// unrecoverable error regardless of what happens inside handleClose
// eslint-disable-next-line no-console
console.error('handleClose errored during unrecoverable error');
// eslint-disable-next-line no-console
console.error(handleCloseErr);
}
}
Expand All @@ -1896,7 +1892,6 @@ export class Client<Ctx = null> {
return;
}

// eslint-disable-next-line no-console
console.error('Please supply your own unrecoverable error handling function');

throw e;
Expand Down
8 changes: 4 additions & 4 deletions src/util/EIOCompat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class EIOCompat implements WebSocket {
this.onclose = null;
this.onmessage = null;
this.onerror = null;
this.eioSocket = eio(uri, { path, transports: ['polling'] });
this.eioSocket = new eio.Socket(uri, { path, transports: ['polling'] });
this.url = url;
this.extensions = '';
this.protocol = '';
Expand Down Expand Up @@ -233,17 +233,14 @@ export class EIOCompat implements WebSocket {
this.setReadyState();
}

// eslint-disable-next-line class-methods-use-this
addEventListener(): boolean {
throw new Error('Not Implemented, please use onmessage, onopen, onerror, or onclose');
}

// eslint-disable-next-line class-methods-use-this
removeEventListener(): void {
throw new Error('Not Implemented');
}

// eslint-disable-next-line class-methods-use-this
dispatchEvent(): boolean {
throw new Error('Not Implemented');
}
Expand All @@ -253,6 +250,9 @@ export class EIOCompat implements WebSocket {
}

get binaryType(): BinaryType {
if (this.eioSocket.binaryType === 'nodebuffer') {
throw new Error('unsupported eioSocket.binaryType nodebuffer');
}
return this.eioSocket.binaryType || 'blob';
}
}
Loading