function-call-composed-name

Try in Playground
javascript-templatesUnknownInformational

0

No tags

No CWE or CVE

Ast Rule: function call


function-call-composed-name

How to write a rule
function visit(node, filename, code) {
  if(node.functionName && node.functionName.astType === "member" &&
     node.functionName.name.value === "log" && 
     node.functionName.parent.astType === "string" &&
     node.functionName.parent.value === "console"
    ){

    const editChangeFunctionCall = buildEditUpdate(node.functionName.name.start.line, node.functionName.name.start.col, node.functionName.name.end.line, node.functionName.name.end.col, "info");
    const fix = buildFix("use info", [editChangeFunctionCall]);

    const error = buildError(node.functionName.start.line, node.functionName.start.col, node.functionName.end.line, node.functionName.end.col, "do not use function bar", "CRITICAL", "SAFETY");
    addError(error.addFix(fix));
  }
}

console.js

Expected test result: has error

console.log("hello world");
Add comment

Log in to add a comment


    Be the first one to leave a comment!

Codiga Logo
Codiga Hub
  • Rulesets
  • Playground
  • Snippets
  • Cookbooks
Legal
  • Security
  • Privacy Policy
  • Code Privacy
  • Terms of Service
soc-2 icon

We are SOC-2 Compliance Certified

G2 high performer medal

Codiga – All rights reserved 2022.