Skip to content

Commit 558cfe7

Browse files
chore: update EsLint rules
1 parent 2744afa commit 558cfe7

67 files changed

Lines changed: 1272 additions & 428 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎eslint.config.js‎

Lines changed: 521 additions & 55 deletions
Large diffs are not rendered by default.

‎package-lock.json‎

Lines changed: 355 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
"mcpName": "io.github.ChromeDevTools/chrome-devtools-mcp",
5656
"devDependencies": {
5757
"@blackwell-systems/gcf": "^2.2.2",
58-
"@eslint/js": "^10.0.1",
5958
"@google/genai": "^2.0.1",
6059
"@modelcontextprotocol/client": "2.1.0",
6160
"@modelcontextprotocol/core": "2.1.0",
@@ -75,7 +74,10 @@
7574
"core-js": "3.50.0",
7675
"eslint": "^10.7.0",
7776
"eslint-import-resolver-typescript": "^4.4.4",
77+
"eslint-plugin-eslint-plugin": "^7.6.2",
7878
"eslint-plugin-import": "^2.32.0",
79+
"eslint-plugin-jsdoc": "^64.5.4",
80+
"eslint-plugin-mocha": "^12.0.2",
7981
"globals": "^17.0.0",
8082
"lighthouse": "13.5.0",
8183
"prettier": "^3.6.2",

‎rollup.config.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
/**
19-
* @fileoverview taken from {@link https://github.com/GoogleChromeLabs/chromium-bidi/blob/main/rollup.config.mjs | chromium-bidi}
19+
* @file taken from {@link https://github.com/GoogleChromeLabs/chromium-bidi/blob/main/rollup.config.mjs | chromium-bidi}
2020
* and modified to specific requirement.
2121
*/
2222

@@ -195,7 +195,7 @@ const bundleDependency = (
195195
const stringifiedDependencies = Array.from(
196196
seenDependencies.values(),
197197
).map(dependency => {
198-
let arr = [];
198+
const arr = [];
199199
arr.push(`Name: ${dependency.name ?? 'N/A'}`);
200200
let url = dependency.homepage ?? dependency.repository;
201201
if (url !== null && typeof url !== 'string') {

‎scripts/eslint_rules/check-license-rule.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default {
7373
nextToken.loc.start.line === header.loc.end.line + 1
7474
) {
7575
context.report({
76-
node: node,
76+
node,
7777
loc: header.loc,
7878
messageId: 'emptyLine',
7979
fix(fixer) {
@@ -87,7 +87,7 @@ export default {
8787
// Add header license
8888
if (!header || !header.value.includes('@license')) {
8989
context.report({
90-
node: node,
90+
node,
9191
messageId: 'licenseRule',
9292
fix(fixer) {
9393
return fixer.insertTextAfterRange(insertAfter, licenseHeader);

‎scripts/eslint_rules/require-parsed-arguments-rule.js‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,8 @@ export default {
8787
const output = `${left}: ParsedArguments = ${right}`;
8888
if (hasParens) {
8989
return fixer.replaceText(firstParam, output);
90-
} else {
91-
return fixer.replaceText(firstParam, `(${output})`);
9290
}
91+
return fixer.replaceText(firstParam, `(${output})`);
9392
} else {
9493
const text = sourceCode.getText(firstParam);
9594
paramName = text.split(':')[0].trim();
@@ -101,12 +100,11 @@ export default {
101100
firstParam,
102101
`${paramName}: ParsedArguments`,
103102
);
104-
} else {
105-
return fixer.replaceText(
106-
firstParam,
107-
`(${paramName}: ParsedArguments)`,
108-
);
109103
}
104+
return fixer.replaceText(
105+
firstParam,
106+
`(${paramName}: ParsedArguments)`,
107+
);
110108
},
111109
});
112110
}

‎scripts/eval_gemini.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import {Client} from '@modelcontextprotocol/client';
1515
import {StdioClientTransport} from '@modelcontextprotocol/client/stdio';
1616
import {TestServer} from '../build/tests/server.js';
1717

18+
import type {CapturedFunctionCall, TestScenario} from './eval_result.js';
19+
import {Result} from './eval_result.js';
20+
1821
const ROOT_DIR = path.resolve(import.meta.dirname, '..');
1922
const SCENARIOS_DIR = path.join(import.meta.dirname, 'eval_scenarios');
2023
const SKILL_PATH = path.join(ROOT_DIR, 'skills', 'chrome-devtools', 'SKILL.md');
21-
22-
import type {CapturedFunctionCall, TestScenario} from './eval_result.js';
23-
import {Result} from './eval_result.js';
2424
export type {CapturedFunctionCall, TestScenario};
2525
export {Result};
2626

‎scripts/eval_result.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ export interface CapturedFunctionCall {
1313

1414
export class Result {
1515
private nextCallIndex = 0;
16-
public readonly calls: CapturedFunctionCall[];
17-
public readonly serverArgs: string[];
16+
readonly calls: CapturedFunctionCall[];
17+
readonly serverArgs: string[];
1818
/** The model's final response text. */
19-
public readonly text: string;
19+
readonly text: string;
2020

2121
constructor(calls: CapturedFunctionCall[], serverArgs: string[], text = '') {
2222
this.calls = calls;

‎scripts/eval_scenarios/page_focus_keyboard_test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ Now use the press_key tool to type "a" on Page 1 without selecting it first. You
4646
pressKeys.length >= 2,
4747
'Should retry press_key after error recovery',
4848
);
49-
const lastPressKeyIndex = result.calls.lastIndexOf(pressKeys.at(-1)!);
49+
const lastPressKey = pressKeys.at(-1);
50+
assert.ok(lastPressKey);
51+
const lastPressKeyIndex = result.calls.lastIndexOf(lastPressKey);
5052
assert.ok(
5153
firstSelectPageIndex < lastPressKeyIndex,
5254
'select_page should precede the successful press_key',

‎scripts/test.js‎

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// Note: can be converted to ts file once node 20 support is dropped.
88
// Node 20 does not support --experimental-strip-types flag.
99

10-
import {spawn, execSync} from 'node:child_process';
10+
import {spawn} from 'node:child_process';
1111
import {readFile} from 'node:fs/promises';
1212
import path from 'node:path';
1313
import process from 'node:process';
@@ -37,22 +37,20 @@ if (userArgs.length > 0) {
3737
}
3838
files.push(testPath);
3939
}
40-
} else {
41-
if (flags.includes('--test-only')) {
42-
const {glob} = await import('node:fs/promises');
43-
for await (const tsFile of glob('tests/**/*.test.ts')) {
44-
const content = await readFile(tsFile, 'utf8');
45-
if (content.includes('.only(')) {
46-
files.push(path.join('build', tsFile.replace(/\.ts$/, '.js')));
47-
}
48-
}
49-
if (files.length === 0) {
50-
console.warn('no files contain .only');
51-
process.exit(0);
40+
} else if (flags.includes('--test-only')) {
41+
const {glob} = await import('node:fs/promises');
42+
for await (const tsFile of glob('tests/**/*.test.ts')) {
43+
const content = await readFile(tsFile, 'utf8');
44+
if (content.includes('.only(')) {
45+
files.push(path.join('build', tsFile.replace(/\.ts$/, '.js')));
5246
}
53-
} else if (files.length === 0) {
54-
files.push('build/tests/**/*.test.js');
5547
}
48+
if (files.length === 0) {
49+
console.warn('no files contain .only');
50+
process.exit(0);
51+
}
52+
} else if (files.length === 0) {
53+
files.push('build/tests/**/*.test.js');
5654
}
5755

5856
const nodeArgs = [
@@ -68,24 +66,11 @@ const nodeArgs = [
6866
...files,
6967
];
7068

71-
function _installChrome(version) {
72-
try {
73-
return execSync(
74-
`npx puppeteer browsers install chrome@${version} --format "{{path}}"`,
75-
)
76-
.toString()
77-
.trim();
78-
} catch (e) {
79-
console.error(`Failed to install Chrome ${version}:`, e);
80-
process.exit(1);
81-
}
82-
}
83-
8469
async function runTests(attempt) {
8570
if (attempt > 1) {
8671
console.log(`\nRun attempt ${attempt}...\n`);
8772
}
88-
return new Promise(resolve => {
73+
return await new Promise(resolve => {
8974
const child = spawn('node', nodeArgs, {
9075
stdio: 'inherit',
9176
env: {

0 commit comments

Comments
 (0)