Skip to content

Commit

Permalink
Docs: clarify options descriptions (fixes #8875) (#9060)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonmailhiot authored and not-an-aardvark committed Aug 5, 2017
1 parent 37158c5 commit c3d5b39
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions docs/rules/no-mixed-operators.md
Expand Up @@ -60,11 +60,8 @@ var foo = (a + b) * c;

This rule has 2 options.

* `groups` (`string[][]`) - specifies groups to compare operators.
When this rule compares two operators, if both operators are included in a same group, this rule checks it. Otherwise, this rule ignores it.
This value is a list of groups. The group is a list of binary operators.
Default is the groups for each kind of operators.
* `allowSamePrecedence` (`boolean`) - specifies to allow mix of 2 operators if those have the same precedence. Default is `true`.
* `groups` (`string[][]`) - specifies operator groups to be checked. The `groups` option is a list of groups, and a group is a list of binary operators. Default operator groups are defined as arithmetic, bitwise, comparison, logical, and relational operators.
* `allowSamePrecedence` (`boolean`) - specifies whether to allow mixed operators if they are of equal precedence. Default is `true`.

### groups

Expand All @@ -76,11 +73,10 @@ The following operators can be used in `groups` option:
* Logical Operators: `"&&"`, `"||"`
* Relational Operators: `"in"`, `"instanceof"`

Now, considers about `{"groups": [["&", "|", "^", "~", "<<", ">>", ">>>"], ["&&", "||"]]}` configure.
This configure has 2 groups: bitwise operators and logical operators.
This rule checks only if both operators are included in a same group.
So, in this case, this rule comes to check between bitwise operators and between logical operators.
This rule ignores other operators.
Now, consider the following group configuration: `{"groups": [["&", "|", "^", "~", "<<", ">>", ">>>"], ["&&", "||"]]}`.
There are 2 groups specified in this configuration: bitwise operators and logical operators.
This rule checks if the operators belong to the same group only.
In this case, this rule checks if bitwise operators and logical operators are mixed, but ignores all other operators.

Examples of **incorrect** code for this rule with `{"groups": [["&", "|", "^", "~", "<<", ">>", ">>>"], ["&&", "||"]]}` option:

Expand Down Expand Up @@ -133,4 +129,4 @@ If you don't want to be notified about mixed operators, then it's safe to disabl

## Related Rules

* [no-extra-parens](no-extra-parens.md)
* [no-extra-parens](no-extra-parens.md)

0 comments on commit c3d5b39

Please sign in to comment.