my-test-rule

Try in Playground
my-test-rule

Codiga Fan #27882

UnknownInformational

0

No tags

No CWE or CVE

Pattern Rule: assert ${something}


my-test-rule

How to write a rule
function visit(nodeOrPattern, filename, code) {
  const exceptionName = nodeOrPattern.variables.get("something");
  if (exceptionName && exceptionName.value === "hyemmi") {
    const error = buildError(
      exceptionName.start.line,
      exceptionName.start.col,
      exceptionName.end.line,
      exceptionName.end.col,
      "do not assert on hyemmi",
      "INFO",
      "BEST_PRACTICES"
    );
    const edit = buildEdit(
      exceptionName.start.line,
      exceptionName.start.col,
      exceptionName.end.line,
      exceptionName.end.col,
      "update",
      "eunju"
    );
    const fix = buildFix("replace by eunju", [edit]);
    addError(error.addFix(fix));
  }
}
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.