Login
varUplevel rule
Login

The rule checks if declarations of local variables can be changed from var to let or const and from let to const. The syntax in a configuration file is:

[ruleType] ?not? varUplevel

Disabling the rule

It is possible to disable the rule for a selected part of the checked code by using pragma ruleOff: "varUplevel" in the element from which the rule should be disabled or in code before it. For example, if the rule should be disabled for variable var i = 1, the full declaration of it can be:

var i {.ruleOff: "varUplevel".} = 1

To enable the rule again, the pragma ruleOn: "varUplevel" should be added in the element which should be checked or in the code before it. For example, if the rule should be re-enabled for const a = 1, the full declaration should be:

const a {.ruleOn: "varUplevel".} = 1

Examples

  1. Check if any declaration of local variable can be updated::

    check varUplevel

  2. Search for declarations of local variables which can't be updated:

    search not varUplevel