mongo/buildscripts/eslint-plugin-mongodb/rules/no-print-fn.js
Zac 591928c619 SERVER-108478 JS formatted by prettier and remove clang-format (#39656)
GitOrigin-RevId: 6c8f6aded47f260aa4f7c231b17dae3302cb1e04
2025-08-21 17:27:09 +00:00

29 lines
944 B
JavaScript

const stopList = ["print", "printjson", "printjsononeline"];
export default {
meta: {
type: "problem",
docs: {
description: "Ensure no direct calls to print* functions",
},
fixable: "code",
},
create(context) {
return {
CallExpression: function (node) {
if (node.callee.type == "Identifier" && stopList.some((fn) => fn == node.callee.name)) {
context.report({
node,
message: `Direct use of '${
node.callee.name
}()'. Consider using jsTest.log.info() instead or disable mongodb/no-print-fn rule when necessary, e.g., '// eslint-disable-next-line mongodb/no-print-fn'
More about rules configuration: https://eslint.org/docs/latest/use/configure/rules`,
});
}
},
};
},
};