check-var-value

Try in Playground
js-rulesBest PracticeWarning

0

No tags

No CWE or CVE

This rule checks if the variable x is greater than 2, and if it is, it prints out the message "x is greater than 2" to the console. Otherwise, it prints out, "x is not greater than 2".

Ast Rule: try block


check-var-value

How to write a rule
let x = 3;
if (x > 2) {
 console.log("x is greater than 2");
} else {
 console.log("x is not greater than 2");
}

test-1.js

Expected test result: no error

const x = 3;
if (x > 2) {
  console.log('x is greater than 2');
} else {
  console.log('x is not greater than 2');
}
Add comment

Log in to add a comment


    Be the first one to leave a comment!

Codiga Logo
Codiga Hub
  • Rulesets
  • Playground
  • Snippets
  • Cookbooks
soc-2 icon

We are SOC-2 Compliance Certified

G2 high performer medal

Codiga – All rights reserved 2022.