Rule
prefer-core-logging (eslint-factory/src/rules/prefer-core-logging.ts)
The rule correctly reports console.log/info/debug and suggests core.info/core.debug. The report is fine; the autofix suggestion is not behavior-preserving for non-string arguments.
console.log(user); // suggests: core.info(user)
console.log({ id: 1 }); // suggests: core.info({ id: 1 })
console.log(count); // suggests: core.info(count)
console.log(obj) runs the value through util.inspect, printing a readable representation. core.info has signature info(message: string) and effectively does process.stdout.write(message + EOL), coercing a non-string to "[object Object]", "undefined", etc. Applying the suggestion silently degrades diagnostic output for a very common logging pattern (objects, arrays, numbers, identifiers of unknown type).
Root cause: canSuggestCoreReplacement (rule lines ~76-83) authorizes the suggestion for any single argument that is not an interpolated template literal and not a console format string. It does not require the argument to be statically string-typed, so identifiers/objects/numbers get a fix offered.
Existing tests
Suggestion tests only cover string literals / no-expression templates / multi-arg (suppressed) cases. No test asserts that a non-string single argument is reported without an unsafe fix.
Proposed refinement
Keep reporting preferCoreLogging for all matched console.* calls, but only attach the replaceWithCoreMethod suggestion when the single argument is statically known to be a string:
- string
Literal, or
TemplateLiteral with no expressions (already the safe subset).
For identifiers / objects / member expressions / numeric literals, report without a suggestion (the author decides how to stringify). This mirrors the existing conservative handling of interpolated templates and format specifiers.
Acceptance criteria
Grounding
No live console.* sites in non-test actions/setup/js/*.cjs today, so this is regression-guard hardening. Confidence: medium-high — the semantic difference between console.log(obj) and core.info(obj) is concrete and the fix is a small tightening of canSuggestCoreReplacement.
Generated by 🤖 ESLint Refiner · 455.7 AIC · ⌖ 10.8 AIC · ⊞ 4.6K · ◷
Rule
prefer-core-logging(eslint-factory/src/rules/prefer-core-logging.ts)The rule correctly reports
console.log/info/debugand suggestscore.info/core.debug. The report is fine; the autofix suggestion is not behavior-preserving for non-string arguments.console.log(obj)runs the value throughutil.inspect, printing a readable representation.core.infohas signatureinfo(message: string)and effectively doesprocess.stdout.write(message + EOL), coercing a non-string to"[object Object]","undefined", etc. Applying the suggestion silently degrades diagnostic output for a very common logging pattern (objects, arrays, numbers, identifiers of unknown type).Root cause:
canSuggestCoreReplacement(rule lines ~76-83) authorizes the suggestion for any single argument that is not an interpolated template literal and not aconsoleformat string. It does not require the argument to be statically string-typed, so identifiers/objects/numbers get a fix offered.Existing tests
Suggestion tests only cover string literals / no-expression templates / multi-arg (suppressed) cases. No test asserts that a non-string single argument is reported without an unsafe fix.
Proposed refinement
Keep reporting
preferCoreLoggingfor all matchedconsole.*calls, but only attach thereplaceWithCoreMethodsuggestion when the single argument is statically known to be a string:Literal, orTemplateLiteralwith no expressions (already the safe subset).For identifiers / objects / member expressions / numeric literals, report without a suggestion (the author decides how to stringify). This mirrors the existing conservative handling of interpolated templates and format specifiers.
Acceptance criteria
console.log("ready")→ reported with thecore.info("ready")suggestion (unchanged).console.log(user)→ reported without any suggestion.console.log({ id: 1 })andconsole.log(count)→ reported without any suggestion.npm testpasses.Grounding
No live
console.*sites in non-testactions/setup/js/*.cjstoday, so this is regression-guard hardening. Confidence: medium-high — the semantic difference betweenconsole.log(obj)andcore.info(obj)is concrete and the fix is a small tightening ofcanSuggestCoreReplacement.