From a5187f70f9be772fb8fedb05ef16c4b2a431be02 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Sat, 29 Jun 2024 23:27:19 +0300 Subject: [PATCH] chore: run eslint --fix --- lib/Logger.js | 2 +- protocols/asa.js | 2 +- protocols/dayz.js | 4 +- protocols/gtasao.js | 2 +- protocols/minetest.js | 4 +- protocols/quake1.js | 2 +- protocols/ragemp.js | 4 +- tools/attempt_protocols.js | 3 +- tools/find-id-changes.js | 98 ++++++++++++++++++------------------- tools/find_id_duplicates.js | 2 +- 10 files changed, 61 insertions(+), 62 deletions(-) diff --git a/lib/Logger.js b/lib/Logger.js index 8e67908..3b75759 100644 --- a/lib/Logger.js +++ b/lib/Logger.js @@ -1,5 +1,5 @@ import { debugDump } from './HexUtil.js' -import { Buffer} from 'node:buffer' +import { Buffer } from 'node:buffer' export default class Logger { constructor () { diff --git a/protocols/asa.js b/protocols/asa.js index 99995c7..7289956 100644 --- a/protocols/asa.js +++ b/protocols/asa.js @@ -10,7 +10,7 @@ export default class asa extends Epic { this.deploymentId = 'ad9a8feffb3b4b2ca315546f038c3ae2' } - async run(state) { + async run (state) { await super.run(state) state.version = state.raw.attributes.BUILDID_s + '.' + state.raw.attributes.MINORBUILDID_s } diff --git a/protocols/dayz.js b/protocols/dayz.js index ce98f8a..7a00ed9 100644 --- a/protocols/dayz.js +++ b/protocols/dayz.js @@ -80,10 +80,10 @@ export default class dayz extends valve { state.raw.dlcEnabled = true } if (tag.includes('privHive')) { - state.raw.privateHive = true; + state.raw.privateHive = true } if (tag.includes('external')) { - state.raw.external = true; + state.raw.external = true } if (tag.includes(':')) { state.raw.time = tag diff --git a/protocols/gtasao.js b/protocols/gtasao.js index cb43f77..7a80e65 100644 --- a/protocols/gtasao.js +++ b/protocols/gtasao.js @@ -1,7 +1,7 @@ import samp from './samp.js' export default class gtasao extends samp { - constructor() { + constructor () { super() this.isOmp = true } diff --git a/protocols/minetest.js b/protocols/minetest.js index ec3641c..97f27bc 100644 --- a/protocols/minetest.js +++ b/protocols/minetest.js @@ -1,12 +1,12 @@ import Core from './core.js' export default class minetest extends Core { - constructor() { + constructor () { super() this.usedTcp = true } - async run(state) { + async run (state) { const servers = await this.request({ url: 'https://servers.minetest.net/list', responseType: 'json' diff --git a/protocols/quake1.js b/protocols/quake1.js index 1299617..318e01c 100644 --- a/protocols/quake1.js +++ b/protocols/quake1.js @@ -7,7 +7,7 @@ export default class quake1 extends quake2 { this.isQuake1 = true } - async run(state) { + async run (state) { await super.run(state) if ('*version' in state.raw) state.version = state.raw['*version'] } diff --git a/protocols/ragemp.js b/protocols/ragemp.js index b1dff3e..101c6e6 100644 --- a/protocols/ragemp.js +++ b/protocols/ragemp.js @@ -1,12 +1,12 @@ import Core from './core.js' export default class ragemp extends Core { - constructor() { + constructor () { super() this.usedTcp = true } - async run(state) { + async run (state) { const results = await this.request({ url: 'https://cdn.rage.mp/master/v2/', responseType: 'json' diff --git a/tools/attempt_protocols.js b/tools/attempt_protocols.js index 29cbfa3..feba5aa 100644 --- a/tools/attempt_protocols.js +++ b/tools/attempt_protocols.js @@ -17,13 +17,12 @@ if (argv._.length >= 1) { const gamedig = new GameDig(options) -let protocolList = [] +const protocolList = [] Object.keys(protocols).forEach((key) => protocolList.push(key)) const services = ['discord', 'beammpmaster', 'beammp', 'teamspeak2', 'teamspeak3'] const protocolListFiltered = protocolList.filter((protocol) => !services.includes(protocol)) - const run = async () => { for (const protocol of protocolListFiltered) { try { diff --git a/tools/find-id-changes.js b/tools/find-id-changes.js index aec3459..a5eeb02 100644 --- a/tools/find-id-changes.js +++ b/tools/find-id-changes.js @@ -1,11 +1,11 @@ #!/usr/bin/env node -import { spawnSync } from "node:child_process"; -import assert from "node:assert"; -import { mkdirSync, copyFileSync } from "node:fs"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; -import process from "node:process"; +import { spawnSync } from 'node:child_process' +import assert from 'node:assert' +import { mkdirSync, copyFileSync } from 'node:fs' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import process from 'node:process' // Generate a list of changes to "lib/games.js" where game IDs have been changed via the git history. // Requires git to be installed. @@ -25,81 +25,81 @@ import process from "node:process"; const main = async (rootDir) => { // Make sure CWD is the root of the repo - process.chdir(rootDir); + process.chdir(rootDir) // Get list of commits that have modified lib/games.js const gitLog = spawnSync( - "git", + 'git', [ - "log", - "--follow", - "--format=%H", - "--diff-filter=M", - "--reverse", - "--", - "lib/games.js", + 'log', + '--follow', + '--format=%H', + '--diff-filter=M', + '--reverse', + '--', + 'lib/games.js' ], - { encoding: "utf-8" } - ); + { encoding: 'utf-8' } + ) // Make a directory to store files in - mkdirSync("game_changes", { recursive: true }); + mkdirSync('game_changes', { recursive: true }) - const output = []; + const output = [] - for (const commitHash of gitLog.stdout.split("\n")) { - if (commitHash.length === 0) continue; + for (const commitHash of gitLog.stdout.split('\n')) { + if (commitHash.length === 0) continue // Checkout lib/games.js before the commit that changed it assert( - spawnSync("git", ["checkout", `${commitHash}^1`, "--", "lib/games.js"]) + spawnSync('git', ['checkout', `${commitHash}^1`, '--', 'lib/games.js']) .status === 0 - ); + ) // We have to copy each state of the file to its own file because node caches imports - const beforeName = `game_changes/${commitHash}-before.js`; - copyFileSync("lib/games.js", beforeName); + const beforeName = `game_changes/${commitHash}-before.js` + copyFileSync('lib/games.js', beforeName) - const before = await import(path.join("../", beforeName)); + const before = await import(path.join('../', beforeName)) // Checkout lib/games.js after the commit that changed it assert( - spawnSync("git", ["checkout", `${commitHash}`, "--", "lib/games.js"]) + spawnSync('git', ['checkout', `${commitHash}`, '--', 'lib/games.js']) .status === 0 - ); + ) - const afterName = `game_changes/${commitHash}-after.js`; - copyFileSync("lib/games.js", afterName); + const afterName = `game_changes/${commitHash}-after.js` + copyFileSync('lib/games.js', afterName) - const after = await import(path.join("../", afterName)); + const after = await import(path.join('../', afterName)) // Find game IDs that were removed and added let removed = Object.keys(before.games).filter( (key) => !(key in after.games) - ); + ) let added = Object.keys(after.games).filter( (key) => !(key in before.games) - ); + ) - const changes = []; + const changes = [] for (const rm of removed) { for (const add of added) { - const beforeGame = before.games[rm]; - const afterGame = after.games[add]; + const beforeGame = before.games[rm] + const afterGame = after.games[add] // Modify game names to ignore case, spaces, and punctuation - const beforeName = beforeGame.name.toLowerCase().replace(/[^a-z]/g, ""); - const afterName = afterGame.name.toLowerCase().replace(/[^a-z]/g, ""); + const beforeName = beforeGame.name.toLowerCase().replace(/[^a-z]/g, '') + const afterName = afterGame.name.toLowerCase().replace(/[^a-z]/g, '') if ( beforeGame.options.protocol === afterGame.options.protocol && (beforeName.includes(afterName) || afterName.includes(beforeName)) ) { - changes.push([rm, add]); - removed = removed.filter((r) => r !== rm); - added = added.filter((a) => a !== add); - break; + changes.push([rm, add]) + removed = removed.filter((r) => r !== rm) + added = added.filter((a) => a !== add) + break } } } @@ -108,18 +108,18 @@ const main = async (rootDir) => { hash: commitHash, changes, removed, - added, - }); + added + }) } // Reset the contents of lib/games.js - spawnSync("git", ["checkout", "--", "lib/games.js"]); + spawnSync('git', ['checkout', '--', 'lib/games.js']) - return output; -}; + return output +} main( // Get the root of the repo: // dir of bin/find-id-changes.js -> /../ - path.join(path.dirname(fileURLToPath(import.meta.url)), "..") -).then((o) => console.log(JSON.stringify(o)), console.error); + path.join(path.dirname(fileURLToPath(import.meta.url)), '..') +).then((o) => console.log(JSON.stringify(o)), console.error) diff --git a/tools/find_id_duplicates.js b/tools/find_id_duplicates.js index 9139181..956d6c3 100644 --- a/tools/find_id_duplicates.js +++ b/tools/find_id_duplicates.js @@ -9,7 +9,7 @@ Object.keys(games).forEach((key) => { } }) -function hasDuplicates(obj) { +function hasDuplicates (obj) { const uniqueSet = new Set() for (const item of obj) {