Skip to content

Commit 98c6431

Browse files
committed
upgrade eslint deps
1 parent 1b6b640 commit 98c6431

20 files changed

+338
-433
lines changed

.eslintignore

-1
This file was deleted.

eslint.config.mjs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import globals from 'globals'
2+
import pluginJs from '@eslint/js'
3+
import tseslint from 'typescript-eslint'
4+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
5+
6+
export default [
7+
{
8+
files: ['**/*.{js,mjs,cjs,ts}'],
9+
},
10+
{
11+
languageOptions: {
12+
globals: {
13+
...globals.browser,
14+
...globals.node,
15+
},
16+
},
17+
},
18+
pluginJs.configs.recommended,
19+
...tseslint.configs.recommended,
20+
{
21+
rules: {
22+
'no-unused-vars': 'off',
23+
'@typescript-eslint/no-unused-vars': [
24+
'error',
25+
{
26+
vars: 'all',
27+
args: 'after-used',
28+
caughtErrors: 'all',
29+
ignoreRestSiblings: false,
30+
reportUsedIgnorePattern: false,
31+
varsIgnorePattern: '^_',
32+
},
33+
],
34+
},
35+
},
36+
eslintPluginPrettierRecommended,
37+
]

examples/customUrlHandler.mjs

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
export default function ({
2-
id,
3-
sessions,
4-
tabIndex,
5-
tabsPerSession,
6-
index,
7-
pid,
8-
}) {
1+
export default function ({ id, sessions, tabIndex, tabsPerSession, index, pid }) {
92
return `https://example.com/${id}/${sessions}/${tabIndex}/${tabsPerSession}/${index}/${pid}`
103
}

package.json

+8-14
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"build:docker": "yarn && docker build --platform linux/amd64 -t ghcr.io/vpalmisano/webrtcperf:devel .",
3939
"push:docker": "docker push ghcr.io/vpalmisano/webrtcperf:devel",
4040
"clean": "rm -rf app.min.js build _docs",
41-
"lint": "eslint --resolve-plugins-relative-to path=. src scripts examples",
41+
"lint": "eslint src scripts examples",
4242
"lint:fix": "yarn lint --fix",
4343
"docs": "tsc -b && node build/src/generate-config-docs.js && typedoc",
4444
"build:linux": "nexe --make=\"-j$(nproc 2> /dev/null || echo 1)\" --verbose --build -i app.min.js -o webrtcperf -r 'scripts/*' -r package.json && gzip -9 -c webrtcperf > webrtcperf_${npm_package_version}_linux.gz",
@@ -51,7 +51,6 @@
5151
"@puppeteer/browsers": "^2.4.0",
5252
"@vpalmisano/throttler": "https://github.com/vpalmisano/throttler#5768cd48665f8ce60a6233db97ef4d0a193494ce",
5353
"axios": "^1.7.7",
54-
"camel-case": "^4.1.2",
5554
"chalk": "^4.1.2",
5655
"change-case": "^4.1.2",
5756
"compression": "^1.7.4",
@@ -80,40 +79,35 @@
8079
"ws": "^8.18.0"
8180
},
8281
"devDependencies": {
82+
"globals": "^15.11.0",
83+
"@eslint/js": "^9.13.0",
8384
"@types/compression": "^1.7.5",
8485
"@types/convict": "^6.1.6",
8586
"@types/convict-format-with-validator": "^6.0.5",
8687
"@types/fast-stats": "^0.0.35",
8788
"@types/node": "^20.16.5",
8889
"@types/node-os-utils": "^1.3.4",
89-
"@types/pem": "^1.14.4",
9090
"@types/pidusage": "^2.0.5",
91-
"@types/ps-tree": "^1.1.6",
9291
"@types/sdp-transform": "^2.4.9",
9392
"@types/sprintf-js": "^1.1.4",
9493
"@types/tar-fs": "^2.0.4",
95-
"@types/uuid": "^9.0.8",
9694
"@types/ws": "^8.5.12",
9795
"@typescript-eslint/eslint-plugin": "^5.62.0",
98-
"@typescript-eslint/parser": "^5.62.0",
99-
"eslint": "^8.57.1",
96+
"@typescript-eslint/parser": "^8.12.2",
97+
"eslint": "^9.13.0",
10098
"eslint-config-prettier": "^9.1.0",
101-
"eslint-config-standard": "^17.1.0",
10299
"eslint-import-resolver-typescript": "^3.6.3",
103100
"eslint-plugin-import": "^2.31.0",
104-
"eslint-plugin-jest": "^28.8.3",
105-
"eslint-plugin-node": "^11.1.0",
106101
"eslint-plugin-prettier": "^5.2.1",
107-
"eslint-plugin-promise": "^6.6.0",
108-
"eslint-plugin-simple-import-sort": "^10.0.0",
109-
"eslint-plugin-unused-imports": "^2.0.0",
102+
"eslint-plugin-simple-import-sort": "^12.1.1",
103+
"eslint-plugin-unused-imports": "^4.1.4",
110104
"nexe": "^4.0.0-rc.6",
111105
"prettier": "^3.3.3",
112106
"terser-webpack-plugin": "^5.3.10",
113107
"ts-loader": "^9.5.1",
114-
"ts-node": "^10.9.2",
115108
"typedoc": "^0.26.10",
116109
"typescript": "^5.6.3",
110+
"typescript-eslint": "^8.12.2",
117111
"webpack": "^5.95.0",
118112
"webpack-cli": "^5.1.4",
119113
"webpack-node-externals": "^3.0.0",

scripts/common.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ webrtcperf.safeStringify = obj => {
1515
return obj.toString()
1616
}
1717
return ret
18-
} catch (err) {
18+
} catch {
1919
return obj.toString()
2020
} finally {
2121
values.clear()

scripts/e2e-network-stats.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ window.collectVideoEndToEndNetworkDelayStats = () => {
1010
return videoEndToEndNetworkDelayStats.mean()
1111
}
1212

13-
// eslint-disable-next-line no-unused-vars
1413
function dumpFrame(encodedFrame, direction, offset = 0, end = 32) {
1514
const data = new Uint8Array(encodedFrame.data)
1615
let bytes = ''
@@ -259,7 +258,7 @@ if (
259258
* @param {string} id
260259
* @param {RTCRtpTransceiver} transceiver
261260
*/
262-
// eslint-disable-next-line no-unused-vars
261+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
263262
const handleTransceiverForInsertableStreams = (id, transceiver) => {
264263
log(`RTCPeerConnection-${id} handleTransceiverForInsertableStreams ${transceiver.direction}`)
265264
if (

scripts/e2e-video-stats.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global webrtcperf, log, loadScript, Tesseract, VideoFrame, createWorker */
1+
/* global webrtcperf, log, loadScript, Tesseract, createWorker */
22

33
/**
44
* Video end-to-end delay stats.

scripts/get-user-media.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
197197
const mediaStream = await nativeGetDisplayMedia(constraints, ...args)
198198
await applyGetDisplayMediaCrop(mediaStream)
199199
collectMediaTracks(mediaStream, () => {
200-
stopFakeScreenshare && stopFakeScreenshare()
200+
if (stopFakeScreenshare) stopFakeScreenshare()
201201
})
202202
return mediaStream
203203
}

scripts/peer-connection-stats.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ window.isRecvTrackEnabled = track => {
1010

1111
const filterUndefined = o =>
1212
Object.fromEntries(
13-
// eslint-disable-next-line no-unused-vars
13+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1414
Object.entries(o).filter(([_, v]) => typeof v === 'string' || isFinite(v)),
1515
)
1616

scripts/save-tracks.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global webrtcperf, log, getParticipantNameForSave, createWorker, VideoFrame, VideoEncoder */
1+
/* global webrtcperf, log, getParticipantNameForSave, createWorker */
22

33
const saveFileWorkerFn = () => {
44
const log = (...args) => {

src/app.ts

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ ${wrap(value.doc, { width: 72, indent: ' ' })}
3737
console.log(out)
3838
process.exit(0)
3939
} else if (process.argv.findIndex(a => a.localeCompare('--version') === 0) !== -1) {
40-
// eslint-disable-next-line @typescript-eslint/no-var-requires
4140
const version = json5.parse(fs.readFileSync(resolvePackagePath('package.json')).toString()).version
4241
console.log(version)
4342
process.exit(0)

src/config.ts

+10-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { existsSync } from 'fs'
44
import os from 'os'
55
import { join } from 'path'
66

7-
// eslint-disable-next-line @typescript-eslint/no-var-requires
7+
// eslint-disable-next-line @typescript-eslint/no-require-imports
88
const puppeteer = require('puppeteer-core')
99

1010
import { logger } from './utils'
@@ -24,13 +24,13 @@ const index = {
2424
validate: (v: boolean | string | number) => {
2525
if (typeof v === 'string') {
2626
if (v === 'true' || v === 'false' || v === '') return
27-
if (v.indexOf('-') !== -1) {
27+
if (v.includes('-')) {
2828
v.split('-').forEach(n => {
2929
if (isNaN(parseInt(n)) || !isFinite(parseInt(n))) throw new Error(`Invalid index: ${n}`)
3030
})
3131
return
3232
}
33-
if (v.indexOf(',') !== -1) {
33+
if (v.includes(',')) {
3434
v.split(',').forEach(n => {
3535
if (isNaN(parseInt(n)) || !isFinite(parseInt(n))) throw new Error(`Invalid index: ${n}`)
3636
})
@@ -814,13 +814,11 @@ function formatDocs(
814814
}
815815

816816
if (property) {
817-
docs[property] =
818-
// eslint-disable-line no-param-reassign
819-
{
820-
doc: schema.doc,
821-
format: JSON.stringify(schema.format, null, 2),
822-
default: JSON.stringify(schema.default, null, 2),
823-
}
817+
docs[property] = {
818+
doc: schema.doc,
819+
format: JSON.stringify(schema.format, null, 2),
820+
default: JSON.stringify(schema.default, null, 2),
821+
}
824822
}
825823
return docs
826824
}
@@ -832,10 +830,10 @@ export function getConfigDocs(): ConfigDocs {
832830
return formatDocs({}, null, configSchema.getSchema())
833831
}
834832

835-
const schemaProperties = configSchema.getProperties()
833+
const _schemaProperties = configSchema.getProperties()
836834

837835
/** [[include:config.md]] */
838-
export type Config = typeof schemaProperties
836+
export type Config = typeof _schemaProperties
839837

840838
/**
841839
* Loads the config object.

src/generate-config-docs.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ data += `
3939

4040
writeFile('docs/config.md', data).then(
4141
() => {
42-
console.log('done'); // eslint-disable-line
42+
console.log('done')
4343
},
4444
err => {
45-
console.error(`Error writing file: ${err.message}`); // eslint-disable-line
45+
console.error(`Error writing file: ${err.message}`)
4646
},
4747
)

src/server.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class Server {
109109
})
110110
}
111111

112-
this.app.use((err: Error, _req: express.Request, res: express.Response, _next: express.NextFunction) => {
112+
this.app.use((err: Error, _req: express.Request, res: express.Response) => {
113113
log.error(`request error: ${err.message}`)
114114
res.status(500).send(err.message)
115115
})
@@ -541,7 +541,7 @@ export class Server {
541541
})
542542

543543
ws.on('message', (data: Uint8Array) => {
544-
if (!data || !data.byteLength) return
544+
if (!data?.byteLength) return
545545
if (!headerWritten) {
546546
stream.write(data)
547547
headerWritten = true

src/session.ts

+13-24
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,9 @@ const PageLogColors = {
9797

9898
type PageLogColorsKey = 'error' | 'warn' | 'info' | 'log' | 'debug' | 'requestfailed'
9999

100-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
101100
type SessionStats = Record<string, number | Record<string, number>>
102101

103-
export type SessionParams = {
102+
export interface SessionParams {
104103
/** The chromium running instance url. */
105104
chromiumUrl: string
106105
/** The chromium executable path. */
@@ -224,9 +223,9 @@ export class Session extends EventEmitter {
224223
private readonly pageLogPath: string
225224
private readonly userAgent: string
226225
private readonly evaluateAfter: {
227-
// eslint-disable-next-line @typescript-eslint/ban-types
226+
// eslint-disable-next-line
228227
pageFunction: Function
229-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
228+
// eslint-disable-next-line
230229
args: any
231230
}[]
232231
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -392,7 +391,7 @@ export class Session extends EventEmitter {
392391
/* this.audioRedForOpus = !!audioRedForOpus */
393392
this.url = url
394393
this.urlQuery = urlQuery
395-
if (!this.urlQuery && url.indexOf('?') !== -1) {
394+
if (!this.urlQuery && url.includes('?')) {
396395
const parts = url.split('?', 2)
397396
this.url = parts[0]
398397
this.urlQuery = parts[1]
@@ -492,15 +491,7 @@ export class Session extends EventEmitter {
492491

493492
if (responseModifiers) {
494493
try {
495-
const parsed = JSON5.parse(responseModifiers) as Record<
496-
string,
497-
{
498-
search?: string
499-
replace?: string
500-
file?: string
501-
headers?: Record<string, string>
502-
}[]
503-
>
494+
const parsed = JSON5.parse(responseModifiers)
504495
Object.entries(parsed).forEach(([url, replacements]) => {
505496
if (!Array.isArray(replacements)) {
506497
throw new Error(
@@ -521,7 +512,7 @@ export class Session extends EventEmitter {
521512

522513
if (downloadResponses) {
523514
try {
524-
const parsed = JSON5.parse(downloadResponses) as { urlPattern: string; output: string; append?: boolean }[]
515+
const parsed = JSON5.parse(downloadResponses)
525516
if (!Array.isArray(parsed)) throw new Error(`downloadResponses should be an array: ${downloadResponses}`)
526517
parsed.forEach(({ urlPattern, output, append }) => {
527518
this.downloadResponses.push({ urlPattern: getUrlPatternRegExp(urlPattern), output, append })
@@ -535,7 +526,7 @@ export class Session extends EventEmitter {
535526

536527
if (cookies) {
537528
try {
538-
this.cookies = JSON5.parse(cookies) as CookieParam[]
529+
this.cookies = JSON5.parse(cookies)
539530
} catch (err) {
540531
log.error(`error parsing cookies: ${(err as Error).stack}`)
541532
}
@@ -833,8 +824,7 @@ export class Session extends EventEmitter {
833824
await Promise.all(
834825
Object.keys(this.exposedFunctions).map(
835826
async (name: string) =>
836-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
837-
await page.exposeFunction(name, (...args: any[]) => this.exposedFunctions[name](...args)),
827+
await page.exposeFunction(name, (...args: unknown[]) => this.exposedFunctions[name](...args)),
838828
),
839829
)
840830

@@ -1275,14 +1265,12 @@ window.SERVER_USE_HTTPS = ${this.serverUseHttps};
12751265
try {
12761266
await page.evaluateOnNewDocument(
12771267
(css: string) => {
1278-
// eslint-disable-next-line no-undef
12791268
document.addEventListener('DOMContentLoaded', () => {
1280-
// eslint-disable-next-line no-undef
12811269
const style = document.createElement('style')
12821270
style.setAttribute('id', 'webrtcperf-extra-style')
12831271
style.setAttribute('type', 'text/css')
12841272
style.innerHTML = css
1285-
// eslint-disable-next-line no-undef
1273+
12861274
document.head.appendChild(style)
12871275
})
12881276
},
@@ -1410,7 +1398,8 @@ window.SERVER_USE_HTTPS = ${this.serverUseHttps};
14101398
}
14111399
}
14121400

1413-
private async getNewPage(_tabIndex: number): Promise<Page> {
1401+
private async getNewPage(tabIndex: number): Promise<Page> {
1402+
log.debug(`getNewPage ${tabIndex}`)
14141403
assert(this.context, 'NoBrowserContextCreated')
14151404
return await this.context.newPage()
14161405
}
@@ -1458,7 +1447,7 @@ window.SERVER_USE_HTTPS = ${this.serverUseHttps};
14581447
/**
14591448
* updateStats
14601449
*/
1461-
async updateStats(_now: number): Promise<SessionStats> {
1450+
async updateStats(): Promise<SessionStats> {
14621451
if (!this.browser) {
14631452
this.stats = {}
14641453
return this.stats
@@ -1618,7 +1607,7 @@ window.SERVER_USE_HTTPS = ${this.serverUseHttps};
16181607
collectedStats as RtcStats,
16191608
pageIndex,
16201609
trackId,
1621-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1610+
16221611
value,
16231612
signalingHost,
16241613
participantName,

0 commit comments

Comments
 (0)