Add eslint (#364)

* Add initial prettier and eslint configs

* Modify prettierrc

* Run eslint on everything

* Actually remove prettier

* Fix some eslints

* Remove label in gs2

* Update CHANGELOG

* Update eslintrc to specify es2021
This commit is contained in:
CosminPerRam 2023-09-19 19:52:35 +03:00 committed by GitHub
parent bff9507189
commit 93a9095d99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
67 changed files with 6960 additions and 5211 deletions

View file

@ -1,70 +1,70 @@
import Core from './core.js';
export default class teamspeak2 extends Core {
async run(state) {
const queryPort = this.options.teamspeakQueryPort || 51234;
await this.withTcp(async socket => {
{
const data = await this.sendCommand(socket, 'sel '+this.options.port);
if(data !== '[TS]') throw new Error('Invalid header');
}
{
const data = await this.sendCommand(socket, 'si');
for (const line of data.split('\r\n')) {
const equals = line.indexOf('=');
const key = equals === -1 ? line : line.substring(0,equals);
const value = equals === -1 ? '' : line.substring(equals+1);
state.raw[key] = value;
}
}
{
const data = await this.sendCommand(socket, 'pl');
const split = data.split('\r\n');
const fields = split.shift().split('\t');
for (const line of split) {
const split2 = line.split('\t');
const player = {};
split2.forEach((value,i) => {
let key = fields[i];
if(!key) return;
if(key === 'nick') key = 'name';
const m = value.match(/^"(.*)"$/);
if(m) value = m[1];
player[key] = value;
});
state.players.push(player);
}
}
{
const data = await this.sendCommand(socket, 'cl');
const split = data.split('\r\n');
const fields = split.shift().split('\t');
state.raw.channels = [];
for (const line of split) {
const split2 = line.split('\t');
const channel = {};
split2.forEach((value,i) => {
const key = fields[i];
if(!key) return;
const m = value.match(/^"(.*)"$/);
if(m) value = m[1];
channel[key] = value;
});
state.raw.channels.push(channel);
}
}
}, queryPort);
}
async sendCommand(socket,cmd) {
return await this.tcpSend(socket, cmd+'\x0A', buffer => {
if(buffer.length < 6) return;
if(buffer.slice(-6).toString() !== '\r\nOK\r\n') return;
return buffer.slice(0,-6).toString();
});
}
}
import Core from './core.js'
export default class teamspeak2 extends Core {
async run (state) {
const queryPort = this.options.teamspeakQueryPort || 51234
await this.withTcp(async socket => {
{
const data = await this.sendCommand(socket, 'sel ' + this.options.port)
if (data !== '[TS]') throw new Error('Invalid header')
}
{
const data = await this.sendCommand(socket, 'si')
for (const line of data.split('\r\n')) {
const equals = line.indexOf('=')
const key = equals === -1 ? line : line.substring(0, equals)
const value = equals === -1 ? '' : line.substring(equals + 1)
state.raw[key] = value
}
}
{
const data = await this.sendCommand(socket, 'pl')
const split = data.split('\r\n')
const fields = split.shift().split('\t')
for (const line of split) {
const split2 = line.split('\t')
const player = {}
split2.forEach((value, i) => {
let key = fields[i]
if (!key) return
if (key === 'nick') key = 'name'
const m = value.match(/^"(.*)"$/)
if (m) value = m[1]
player[key] = value
})
state.players.push(player)
}
}
{
const data = await this.sendCommand(socket, 'cl')
const split = data.split('\r\n')
const fields = split.shift().split('\t')
state.raw.channels = []
for (const line of split) {
const split2 = line.split('\t')
const channel = {}
split2.forEach((value, i) => {
const key = fields[i]
if (!key) return
const m = value.match(/^"(.*)"$/)
if (m) value = m[1]
channel[key] = value
})
state.raw.channels.push(channel)
}
}
}, queryPort)
}
async sendCommand (socket, cmd) {
return await this.tcpSend(socket, cmd + '\x0A', buffer => {
if (buffer.length < 6) return
if (buffer.slice(-6).toString() !== '\r\nOK\r\n') return
return buffer.slice(0, -6).toString()
})
}
}