# Ecmascript Rules

Index of all built-in rules available for Ecmascript
Edit me

## Best Practices

Rules which enforce generally accepted best practices.

- AvoidWithStatement: Avoid using with - it’s bad news
- ConsistentReturn: ECMAScript does provide for return types on functions, and therefore there is no solid rule as to…
- GlobalVariable: This rule helps to avoid using accidently global variables by simply missing the "var" declaratio…
- ScopeForInVariable: A for-in loop in which the variable name is not explicitly scoped to the enclosing scope with the…
- UseBaseWithParseInt: This rule checks for usages of parseInt. While the second parameter is optional and usually defau…

## Code Style

Rules which enforce a specific coding style.

- AssignmentInOperand: Avoid assignments in operands; this can make code more complicated and harder to read. This is s…
- ForLoopsMustUseBraces: Avoid using ‘for’ statements without using curly braces.
- IfElseStmtsMustUseBraces: Avoid using if..else statements without using curly braces.
- IfStmtsMustUseBraces: Avoid using if statements without using curly braces.
- NoElseReturn: The else block in a if-else-construct is unnecessary if the ‘if’ block contains a return. Then th…
- UnnecessaryBlock: An unnecessary Block is present. Such Blocks are often used in other languages to introduce a ne…
- UnnecessaryParentheses: Unnecessary parentheses should be removed.
- UnreachableCode: A ‘return’, ‘break’, ‘continue’, or ‘throw’ statement should be the last in a block. Statements a…
- WhileLoopsMustUseBraces: Avoid using ‘while’ statements without using curly braces.

## Error Prone

Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.

- AvoidTrailingComma: This rule helps improve code portability due to differences in browser treatment of trailing comm…
- EqualComparison: Using == in condition may lead to unexpected results, as the variables are automatically casted t…
- InnaccurateNumericLiteral: The numeric literal will have a different value at runtime, which can happen if you provide too m…

## Additional rulesets

- Basic Ecmascript (`rulesets/ecmascript/basic.xml`):

  Deprecated This ruleset is for backwards compatibility.

  It contains the following rules:

  AssignmentInOperand, AvoidTrailingComma, ConsistentReturn, EqualComparison, GlobalVariable, InnaccurateNumericLiteral, ScopeForInVariable, UnreachableCode, UseBaseWithParseInt

- Braces (`rulesets/ecmascript/braces.xml`):

  Deprecated This ruleset is for backwards compatibility.

  It contains the following rules:

  ForLoopsMustUseBraces, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, WhileLoopsMustUseBraces

- Controversial Ecmascript (`rulesets/ecmascript/controversial.xml`):

  Deprecated This ruleset is for backwards compatibility.

  It contains the following rules:

  AvoidWithStatement

- Unnecessary (`rulesets/ecmascript/unnecessary.xml`):

  Deprecated This ruleset is for backwards compatibility.

  It contains the following rules:

  NoElseReturn, UnnecessaryBlock, UnnecessaryParentheses

Tags: rule_references