add eslint for ts
This commit is contained in:
parent
1daa092eea
commit
42a626629b
2
.eslintignore
Normal file
2
.eslintignore
Normal file
@ -0,0 +1,2 @@
|
||||
src/
|
||||
dist/
|
22
.eslintrc.json
Normal file
22
.eslintrc.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true,
|
||||
"mocha": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"no-var": "error",
|
||||
"no-console": "off",
|
||||
"@typescript-eslint/camelcase": "off"
|
||||
}
|
||||
}
|
762
package-lock.json
generated
762
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -15,10 +15,10 @@
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"clean": "rimraf ./dist",
|
||||
"lint": "tslint -c tslint.json -p tsconfig.json --fix",
|
||||
"lint": "eslint --ext .js,.ts .",
|
||||
"tsc": "tsc",
|
||||
"prebuild": "npm run lint",
|
||||
"test": "npm run lint && npm run build && mocha \"test/**/*.js\"",
|
||||
"test": "npm run lint && mocha -r ts-node/register \"test/**/*\"",
|
||||
"start": "bin/peerjs --port ${PORT:=9000}",
|
||||
"dev:start": "npm-run-all build start",
|
||||
"dev": "nodemon --watch src -e ts --exec npm run dev:start"
|
||||
@ -40,17 +40,19 @@
|
||||
"@types/chai": "^4.1.7",
|
||||
"@types/mocha": "^5.2.7",
|
||||
"@types/node": "^10.14.16",
|
||||
"@typescript-eslint/eslint-plugin": "^2.0.0",
|
||||
"@typescript-eslint/parser": "^2.0.0",
|
||||
"chai": "^4.2.0",
|
||||
"eslint": "^6.2.1",
|
||||
"mocha": "^6.2.0",
|
||||
"nodemon": "^1.19.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"rimraf": "^3.0.0",
|
||||
"sinon": "^7.4.1",
|
||||
"ts-node": "^8.3.0",
|
||||
"tslint": "^5.19.0",
|
||||
"typescript": "^3.5.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,17 +4,19 @@ import { IRealm } from "../../models/realm";
|
||||
|
||||
const DEFAULT_CHECK_INTERVAL = 300;
|
||||
|
||||
type CustomConfig = Pick<IConfig, 'alive_timeout'>;
|
||||
|
||||
export class CheckBrokenConnections {
|
||||
|
||||
public readonly checkInterval: number;
|
||||
private timeoutId: NodeJS.Timeout;
|
||||
private readonly realm: IRealm;
|
||||
private readonly config: IConfig;
|
||||
private readonly config: CustomConfig;
|
||||
private readonly onClose?: (client: IClient) => void;
|
||||
|
||||
constructor({ realm, config, checkInterval = DEFAULT_CHECK_INTERVAL, onClose }: {
|
||||
realm: IRealm,
|
||||
config: IConfig,
|
||||
config: CustomConfig,
|
||||
checkInterval?: number,
|
||||
onClose?: (client: IClient) => void
|
||||
}) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
const { expect } = require('chai');
|
||||
const { Client } = require('../../../../dist/src/models/client');
|
||||
const { HeartbeatHandler } = require('../../../../dist/src/messageHandler/handlers');
|
||||
import { expect } from 'chai';
|
||||
import { Client } from '../../../../src/models/client';
|
||||
import { HeartbeatHandler } from '../../../../src/messageHandler/handlers';
|
||||
|
||||
describe('Heartbeat handler', () => {
|
||||
it('should update last ping time', () => {
|
@ -1,6 +1,6 @@
|
||||
const { expect } = require('chai');
|
||||
const { Realm } = require('../../dist/src/models/realm');
|
||||
const { Client } = require('../../dist/src/models/client');
|
||||
import { expect } from 'chai';
|
||||
import { Realm } from '../../src/models/realm';
|
||||
import { Client } from '../../src/models/client';
|
||||
|
||||
describe('Realm', () => {
|
||||
describe('#generateClientId', () => {
|
@ -1,7 +1,7 @@
|
||||
const { expect } = require('chai');
|
||||
const { Client } = require('../../../dist/src/models/client');
|
||||
const { Realm } = require('../../../dist/src/models/realm');
|
||||
const { CheckBrokenConnections } = require('../../../dist/src/services/checkBrokenConnections');
|
||||
import { expect } from 'chai';
|
||||
import { Client } from '../../../src/models/client';
|
||||
import { Realm } from '../../../src/models/realm';
|
||||
import { CheckBrokenConnections } from '../../../src/services/checkBrokenConnections';
|
||||
|
||||
describe('checkBrokenConnections service', () => {
|
||||
it('should remove client after 2 checks', (done) => {
|
20
tslint.json
20
tslint.json
@ -1,20 +0,0 @@
|
||||
{
|
||||
"defaultSeverity": "error",
|
||||
"extends": [
|
||||
"tslint:recommended"
|
||||
],
|
||||
"jsRules": {},
|
||||
"rules": {
|
||||
"trailing-comma": [
|
||||
false
|
||||
],
|
||||
"object-literal-sort-keys": false
|
||||
},
|
||||
"rulesDirectory": [],
|
||||
"linterOptions": {
|
||||
"exclude": [
|
||||
"./bin/",
|
||||
"./test/"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user