Skip to content

Commit ae0a762

Browse files
committed
chore: Adjust lint rule for console logging
1 parent e5a81cb commit ae0a762

31 files changed

+140
-24
lines changed

js/eslint.config.ts

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,30 +82,6 @@ export default [
8282
"@typescript-eslint/no-empty-object-type": "error",
8383
"@typescript-eslint/no-unsafe-function-type": "error",
8484
"@typescript-eslint/prefer-as-const": "error",
85-
// Require node: protocol for Node.js built-in imports (for Deno compatibility)
86-
// This plugin automatically detects ALL Node.js built-ins - no manual list needed!
87-
"node-import/prefer-node-protocol": "error",
88-
},
89-
},
90-
{
91-
files: ["src/**/*.ts", "src/**/*.tsx"],
92-
ignores: [
93-
"src/cli/**",
94-
"src/debug-logger.ts",
95-
"src/framework.ts",
96-
"src/framework2.ts",
97-
"src/isomorph.ts",
98-
"src/sandbox.ts",
99-
"src/template/**",
100-
"src/reporters/**",
101-
"src/prompt-cache/**",
102-
"src/eval-parameters.ts",
103-
"src/wrappers/**",
104-
"src/instrumentation/**",
105-
"src/auto-instrumentations/**",
106-
"src/queue.bench.ts",
107-
],
108-
rules: {
10985
"no-restricted-properties": [
11086
"error",
11187
{
@@ -139,6 +115,35 @@ export default [
139115
message: "Use debugLogger instead of console for SDK logging.",
140116
},
141117
],
118+
// Require node: protocol for Node.js built-in imports (for Deno compatibility)
119+
// This plugin automatically detects ALL Node.js built-ins - no manual list needed!
120+
"node-import/prefer-node-protocol": "error",
121+
},
122+
},
123+
{
124+
files: ["src/queue.bench.ts"],
125+
rules: {
126+
"no-restricted-properties": "off",
127+
},
128+
},
129+
{
130+
files: ["src/**/*.ts", "src/**/*.tsx"],
131+
ignores: [
132+
"src/cli/**",
133+
"src/debug-logger.ts",
134+
"src/framework.ts",
135+
"src/framework2.ts",
136+
"src/isomorph.ts",
137+
"src/sandbox.ts",
138+
"src/template/**",
139+
"src/reporters/**",
140+
"src/prompt-cache/**",
141+
"src/eval-parameters.ts",
142+
"src/wrappers/**",
143+
"src/instrumentation/**",
144+
"src/auto-instrumentations/**",
145+
],
146+
rules: {
142147
"no-restricted-imports": [
143148
"error",
144149
{

js/src/cli/functions/infer-source.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export async function findCodeDefinition({
7171
if (location.type === "experiment" || location.type === "sandbox") {
7272
const evaluator = outFileModule.evaluators[location.eval_name]?.evaluator;
7373
if (!evaluator) {
74+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
7475
console.warn(
7576
warning(
7677
`Warning: failed to find evaluator for ${location.eval_name}. Will not display preview.`,
@@ -94,6 +95,7 @@ export async function findCodeDefinition({
9495
}
9596

9697
if (!fn) {
98+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
9799
console.warn(
98100
warning(
99101
`Warning: failed to find ${locationToString(location)}. Will not display preview.`,
@@ -118,6 +120,7 @@ export async function findCodeDefinition({
118120
}
119121

120122
if (columnNumber === -1) {
123+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
121124
console.warn(
122125
warning(
123126
`Warning: failed to find code definition for ${fn.name}. Will not display preview.`,
@@ -195,6 +198,7 @@ async function getTsModule() {
195198
try {
196199
tsModule = require("typescript");
197200
} catch {
201+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
198202
console.warn(
199203
warning(
200204
"Failed to load TypeScript module. Will not use TypeScript to derive preview.",

js/src/cli/functions/upload.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export async function uploadHandleBundles({
8282
setCurrent: boolean;
8383
defaultIfExists: IfExists;
8484
}) {
85+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
8586
console.error(
8687
`Processing ${buildResults.length} ${pluralize("file", buildResults.length)}...`,
8788
);
@@ -276,6 +277,7 @@ export async function uploadHandleBundles({
276277
const numUploaded = uploadResults.length;
277278
const numFailed = uploadResults.filter((result) => !result).length;
278279

280+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
279281
console.error(
280282
`${numUploaded} ${pluralize("file", numUploaded)} uploaded ${
281283
numFailed > 0
@@ -344,12 +346,14 @@ async function uploadBundles({
344346
);
345347
} catch (e) {
346348
if (showDetailedErrors) {
349+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
347350
console.error(e);
348351
}
349352
const msg =
350353
e instanceof FailedHTTPResponse
351354
? `Unable to upload your code. ${e.status} (${e.text}): ${e.data}`
352355
: `Unable to upload your code. You most likely need to update the API: ${e}`;
356+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
353357
console.error(warning(msg));
354358
return false;
355359
}
@@ -422,12 +426,14 @@ async function uploadBundles({
422426
});
423427
} catch (e) {
424428
if (showDetailedErrors) {
429+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
425430
console.error(e);
426431
}
427432
const msg =
428433
e instanceof FailedHTTPResponse
429434
? `Failed to save function definitions for '${sourceFile}'. ${e.status} (${e.text}): ${e.data}`
430435
: `Failed to save function definitions for '${sourceFile}'. You most likely need to update the API: ${e}`;
436+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
431437
console.warn(warning(msg));
432438
return false;
433439
}

js/src/cli/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ async function initExperiment(
127127
fallback: (_text: string, url: string) => url,
128128
})
129129
: "locally";
130+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
130131
console.error(
131132
chalk.cyan("▶") +
132133
` Experiment ${chalk.bold(info.experimentName)} is running at ${linkText}`,
@@ -219,13 +220,17 @@ function buildWatchPluginForEvaluator(
219220
name: "run-evalutator-on-end",
220221
setup(build: esbuild.PluginBuild) {
221222
build.onEnd(async (result) => {
223+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
222224
console.error(`Done building ${inFile}`);
223225

224226
if (!result.outputFiles) {
225227
if (opts.showDetailedErrors) {
228+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
226229
console.warn(`Failed to compile ${inFile}`);
230+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
227231
console.warn(result.errors);
228232
} else {
233+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
229234
console.warn(`Failed to compile ${inFile}: ${result.errors}`);
230235
}
231236
return;
@@ -306,6 +311,7 @@ function buildWatchPluginForEvaluator(
306311
)) {
307312
const success = await reporter.reportRun(await Promise.all(results));
308313
if (!success) {
314+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
309315
console.error(error(`Reporter ${reporterName} failed.`));
310316
}
311317
}
@@ -421,9 +427,12 @@ export function handleBuildFailure({
421427
if (terminateOnFailure) {
422428
throw result.error;
423429
} else if (showDetailedErrors) {
430+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
424431
console.warn(`Failed to compile ${result.sourceFile}`);
432+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
425433
console.warn(result.error);
426434
} else {
435+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
427436
console.warn(
428437
`Failed to compile ${result.sourceFile}: ${result.error.message}`,
429438
);
@@ -466,6 +475,7 @@ function updateEvaluators(
466475
evaluators.reporters[reporterName] &&
467476
evaluators.reporters[reporterName] !== reporter
468477
) {
478+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
469479
console.warn(
470480
warning(
471481
`Reporter '${reporterName}' already exists. Will skip '${reporterName}' from ${result.sourceFile}.`,
@@ -486,12 +496,14 @@ async function runAndWatch({
486496
onExit?: () => void;
487497
}) {
488498
const count = Object.keys(handles).length;
499+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
489500
console.error(`Watching ${pluralize("file", count, true)}...`);
490501

491502
Object.values(handles).map((handle) => handle.watch());
492503

493504
["SIGINT", "SIGTERM"].forEach((signal: string) => {
494505
process.on(signal, function () {
506+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
495507
console.error("Stopped watching.");
496508
for (const handle of Object.values(handles)) {
497509
handle.destroy();
@@ -540,6 +552,7 @@ async function runOnce(
540552

541553
if (opts.list) {
542554
for (const evaluator of evaluators.evaluators) {
555+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
543556
console.log(evaluator.evaluator.evalName);
544557
}
545558
return true;
@@ -581,13 +594,15 @@ async function runOnce(
581594
}
582595
});
583596

597+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
584598
console.error(
585599
chalk.dim(
586600
`Processing ${chalk.bold(resultPromises.length)} evaluator${resultPromises.length === 1 ? "" : "s"}...`,
587601
),
588602
);
589603
const allEvalsResults = await Promise.all(resultPromises);
590604
opts.progressReporter.stop();
605+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
591606
console.error("");
592607

593608
const evalReports: Record<
@@ -685,6 +700,7 @@ async function collectFiles(
685700
try {
686701
pathStat = fs.lstatSync(inputPath);
687702
} catch (e) {
703+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
688704
console.error(error(`Error reading ${inputPath}: ${e}`));
689705
process.exit(1);
690706
}
@@ -699,6 +715,7 @@ async function collectFiles(
699715
)
700716
) {
701717
const prefix = mode === "eval" ? ".eval" : "";
718+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
702719
console.warn(
703720
warning(
704721
`Reading ${inputPath} because it was specified directly. Rename it to end in ${prefix}.ts or ` +
@@ -848,6 +865,7 @@ export async function initializeHandles({
848865
for (const inputPath of inputPaths) {
849866
const newFiles = await collectFiles(inputPath, mode);
850867
if (newFiles.length == 0) {
868+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
851869
console.warn(
852870
warning(
853871
`Provided path ${inputPath} is not an eval file or a directory containing eval files, skipping...`,
@@ -860,6 +878,7 @@ export async function initializeHandles({
860878
}
861879

862880
if (Object.keys(files).length == 0) {
881+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
863882
console.warn(
864883
warning("No eval files were found in any of the provided paths."),
865884
);
@@ -906,6 +925,7 @@ async function run(args: RunArgs) {
906925
// Load via dotenv library
907926
const loaded = dotenv.config({ path: args.env_file });
908927
if (loaded.error) {
928+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
909929
console.error(error(`Error loading ${args.env_file}: ${loaded.error}`));
910930
process.exit(1);
911931
}
@@ -930,6 +950,7 @@ async function run(args: RunArgs) {
930950
};
931951

932952
if (args.list && args.watch) {
953+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
933954
console.error(error("Cannot specify both --list and --watch."));
934955
process.exit(1);
935956
}

js/src/cli/reporters/eval.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export const fancyReporter: ReporterDef<boolean> = {
174174
);
175175

176176
if (failingResults.length > 0) {
177+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
177178
console.error(
178179
warning(
179180
`Evaluator ${evaluator.evalName} failed with ${pluralize("error", failingResults.length, true)}. This evaluation ("${evaluator.evalName}") will not be fully logged.`,
@@ -186,6 +187,7 @@ export const fancyReporter: ReporterDef<boolean> = {
186187
}
187188
} else if (verbose) {
188189
for (const result of failingResults) {
190+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
189191
console.error(result);
190192
}
191193
}

js/src/cli/util/bundle.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export async function loadCLIEnv(args: AuthArgs & CommonArgs) {
2020
// Load via dotenv library
2121
const loaded = dotenv.config({ path: args.env_file });
2222
if (loaded.error) {
23+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
2324
console.error(error(`Error loading ${args.env_file}: ${loaded.error}`));
2425
process.exit(1);
2526
}

js/src/cli/util/debug-logging.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export function normalizeDebugLoggingArgs<
2121

2222
if (!hasWarnedAboutVerboseFlag) {
2323
hasWarnedAboutVerboseFlag = true;
24+
// eslint-disable-next-line no-restricted-properties -- preserving intentional console usage.
2425
console.warn(warning(VERBOSE_DEPRECATION_MESSAGE));
2526
}
2627

0 commit comments

Comments
 (0)