replace tslint with eslint

This commit is contained in:
Evert Prants 2021-12-15 18:33:13 +02:00
parent 1c98747c62
commit ffee7103e0
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
9 changed files with 2722 additions and 173 deletions

1
.eslintignore Normal file
View File

@ -0,0 +1 @@
*.js

47
.eslintrc.js Normal file
View File

@ -0,0 +1,47 @@
module.exports = {
'env': {
'es2021': true,
'node': true
},
'extends': [
'eslint:recommended',
'plugin:@typescript-eslint/recommended'
],
'parser': '@typescript-eslint/parser',
'parserOptions': {
'ecmaVersion': 13,
'sourceType': 'module',
'project': 'tsconfig.json',
'tsconfigRootDir': __dirname,
},
'plugins': [
'@typescript-eslint'
],
'rules': {
'no-empty': [
'error',
{
'allowEmptyCatch': true,
}
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'indent': [
'error',
2
],
'linebreak-style': [
'error',
'unix'
],
'quotes': [
'error',
'single'
],
'semi': [
'error',
'always'
]
}
};

3
.gitignore vendored
View File

@ -2,5 +2,6 @@
/.out/
deployment.json
*.js
!.eslintrc.js
*.d.ts
*.tsbuildinfo
*.tsbuildinfo

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import {
Plugin,
EventListener,
@ -16,7 +17,7 @@ import tls, { TLSSocket } from 'tls';
import net, { Server, Socket } from 'net';
interface ControlCommand {
execute: Function;
execute: (p: ControlPlugin, ...args: any[]) => Promise<any>;
name: string;
plugin: string;
}
@ -647,7 +648,7 @@ class ControlPlugin extends Plugin {
});
}, (err) => {
logger.error('[%s] Secure socket listen failed: %s',
this.name, err.message);
this.name, err.message);
});
return;
}

2616
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,7 @@
"devDependencies": {
"@types/node": "^16.7.10",
"@types/node-cron": "^2.0.4",
"@types/ws": "^8.2.0"
"@types/ws": "^8.2.0",
"@typescript-eslint/eslint-plugin": "^5.7.0"
}
}

View File

@ -161,10 +161,11 @@ class SqueebotCommandsAPIPlugin extends Plugin {
}
public async handlePrefix(
msg: IMessage,
prefix: string,
plugins: string[],
msr: MessageResolver): Promise<void> {
msg: IMessage,
prefix: string,
plugins: string[],
msr: MessageResolver
): Promise<void> {
const text = msg.text;
const separate = text.split(' ');
if (separate[0].indexOf(prefix) === 0) {
@ -214,9 +215,12 @@ class SqueebotCommandsAPIPlugin extends Plugin {
const permitted = this.permissionMatcher(msg, sorted);
// Rate limit check
if (permitted.length &&
this.config.get('rateLimits', []).length &&
this.doLimiting(msg.fullRoomID!, msg.fullSenderID!)) {
if (permitted.length
&& msg.fullRoomID
&& msg.fullSenderID
&& this.config.get('rateLimits', []).length
&& this.doLimiting(msg.fullRoomID, msg.fullSenderID)
) {
logger.warn('[%s] User %s rate limited', this.name, msg.fullSenderID);
return;
}
@ -494,39 +498,39 @@ class SqueebotCommandsAPIPlugin extends Plugin {
escaped = true;
}
switch (strArray[strChar]) {
case '\\':
if (!escaped) {
escape = true;
} else {
addToArgs('\\');
}
break;
case '"':
if (!escaped) {
if (!isString) {
isString = true;
} else {
isString = false;
}
} else {
addToArgs('"');
}
break;
case ' ':
case '\\':
if (!escaped) {
escape = true;
} else {
addToArgs('\\');
}
break;
case '"':
if (!escaped) {
if (!isString) {
strARGC++;
} else if (isString) {
if (escaped) {
addToArgs('\\');
}
addToArgs(' ');
isString = true;
} else {
isString = false;
}
break;
default:
} else {
addToArgs('"');
}
break;
case ' ':
if (!isString) {
strARGC++;
} else if (isString) {
if (escaped) {
addToArgs('\\');
}
addToArgs(strArray[strChar]);
addToArgs(' ');
}
break;
default:
if (escaped) {
addToArgs('\\');
}
addToArgs(strArray[strChar]);
}
}
return strARGS;
@ -540,11 +544,12 @@ class SqueebotCommandsAPIPlugin extends Plugin {
usage: '[<command>]',
description: 'Show command usage or list all available commands',
execute: async (
msg: IMessage,
msr: MessageResolver,
spec: CommandSpec,
prefix: string,
...args: any[]): Promise<boolean> => {
msg: IMessage,
msr: MessageResolver,
spec: CommandSpec,
prefix: string,
...args: any[]
): Promise<boolean> => {
this.helpCommand(msg, prefix, args);
return true;
}
@ -557,11 +562,12 @@ class SqueebotCommandsAPIPlugin extends Plugin {
usage: '<command>',
description: 'Show the list of aliases for command',
execute: async (
msg: IMessage,
msr: MessageResolver,
spec: CommandSpec,
prefix: string,
...args: any[]): Promise<boolean> => {
msg: IMessage,
msr: MessageResolver,
spec: CommandSpec,
prefix: string,
...args: any[]
): Promise<boolean> => {
this.aliasesCommand(msg, prefix, args);
return true;
}

View File

@ -1,122 +0,0 @@
{
"extends": "tslint:recommended",
"rules": {
"align": {
"options": [
"parameters",
"statements"
]
},
"array-type": false,
"arrow-return-shorthand": true,
"curly": true,
"deprecation": {
"severity": "warning"
},
"eofline": true,
"import-spacing": true,
"indent": {
"options": [
"spaces"
]
},
"max-classes-per-file": false,
"max-line-length": [
true,
140
],
"member-ordering": [
true,
{
"order": [
"static-field",
"instance-field",
"static-method",
"instance-method"
]
}
],
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-empty": false,
"no-inferrable-types": [
true,
"ignore-params"
],
"no-non-null-assertion": false,
"no-redundant-jsdoc": true,
"no-switch-case-fall-through": true,
"no-var-requires": false,
"object-literal-key-quotes": [
true,
"as-needed"
],
"quotemark": [
true,
"single"
],
"semicolon": {
"options": [
"always"
]
},
"space-before-function-paren": {
"options": {
"anonymous": "never",
"asyncArrow": "always",
"constructor": "never",
"method": "never",
"named": "never"
}
},
"typedef": [
true,
"call-signature"
],
"forin": false,
"ban-types": {
"function": false
},
"typedef-whitespace": {
"options": [
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
},
{
"call-signature": "onespace",
"index-signature": "onespace",
"parameter": "onespace",
"property-declaration": "onespace",
"variable-declaration": "onespace"
}
]
},
"variable-name": {
"options": [
"ban-keywords",
"check-format",
"allow-pascal-case"
]
},
"whitespace": {
"options": [
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type",
"check-typecast"
]
}
}
}

View File

@ -46,7 +46,7 @@ class XProtocolPlugin extends Plugin {
this.on('send', (data: any[]) => {
const target = data[0];
this.sendTo(target, ...data.slice(1)).catch((error: Error) => {
logger.error(`[xprotocol] Sending to protocol from event failed:`, error.message ?? error);
logger.error('[xprotocol] Sending to protocol from event failed:', error.message ?? error);
});
});
}