Login
varDeclared rule
Login

The rule to check if the selected variable declaration (var, let and const) has declared type and or value The syntax in a configuration file is:

[ruleType] ?not? varDeclared [declarationType]

Disabling the rule

It is possible to disable the rule for a selected part of the checked code by using pragma ruleOff: "varDeclared" in the declaration from which the rule should be disabled. For example, if the rule should be disabled for variable var a: int, the full declaration of it should be::

var a: int {.ruleOff: "varDeclared".}

To enable the rule again, the pragma ruleOn: "varDeclared" should be added in the element which should be checked. For example, if the rule should be re-enabled for variable let b = 2, the full declaration should be::

let b = 2 {.ruleOn: "varDeclared".}

Examples

  1. Check if all declarations have set type and value for them::

check varDeclared full

  1. Search for all declarations which don't set type for them::

search not varDeclared type