Permalink
Browse files

Docs: Add linting for second half of rule docs (refs #2271)

  • Loading branch information...
1 parent 2551594 commit 850f0cc97d5c9a002492703ee731e5c426415c05 @IanVS IanVS committed Aug 29, 2015
Showing with 1,694 additions and 1,214 deletions.
  1. +4 −1 .editorconfig
  2. +3 −3 docs/rules/brace-style.md
  3. +7 −3 docs/rules/func-style.md
  4. +1 −1 docs/rules/no-div-regex.md
  5. +6 −6 docs/rules/no-dupe-keys.md
  6. +1 −1 docs/rules/no-empty-label.md
  7. +13 −7 docs/rules/no-fallthrough.md
  8. +7 −3 docs/rules/no-floating-decimal.md
  9. +9 −3 docs/rules/no-func-assign.md
  10. +19 −5 docs/rules/no-implicit-coercion.md
  11. +9 −5 docs/rules/no-implied-eval.md
  12. +10 −14 docs/rules/no-inline-comments.md
  13. +24 −10 docs/rules/no-inner-declarations.md
  14. +8 −12 docs/rules/no-invalid-regexp.md
  15. +23 −63 docs/rules/no-invalid-this.md
  16. +13 −10 docs/rules/no-irregular-whitespace.md
  17. +7 −3 docs/rules/no-iterator.md
  18. +5 −1 docs/rules/no-label-var.md
  19. +9 −6 docs/rules/no-labels.md
  20. +17 −5 docs/rules/no-lone-blocks.md
  21. +13 −9 docs/rules/no-lonely-if.md
  22. +9 −14 docs/rules/no-loop-func.md
  23. +16 −7 docs/rules/no-mixed-requires.md
  24. +36 −20 docs/rules/no-mixed-spaces-and-tabs.md
  25. +16 −22 docs/rules/no-multi-spaces.md
  26. +6 −2 docs/rules/no-multi-str.md
  27. +16 −14 docs/rules/no-multiple-empty-lines.md
  28. +4 −2 docs/rules/no-native-reassign.md
  29. +33 −3 docs/rules/no-negated-in-lhs.md
  30. +6 −2 docs/rules/no-nested-ternary.md
  31. +6 −2 docs/rules/no-new-func.md
  32. +6 −2 docs/rules/no-new-object.md
  33. +5 −1 docs/rules/no-new-require.md
  34. +10 −6 docs/rules/no-new-wrappers.md
  35. +5 −1 docs/rules/no-new.md
  36. +6 −2 docs/rules/no-obj-calls.md
  37. +8 −4 docs/rules/no-octal-escape.md
  38. +9 −5 docs/rules/no-octal.md
  39. +13 −15 docs/rules/no-param-reassign.md
  40. +5 −2 docs/rules/no-path-concat.md
  41. +6 −2 docs/rules/no-plusplus.md
  42. +5 −1 docs/rules/no-process-env.md
  43. +6 −2 docs/rules/no-process-exit.md
  44. +6 −2 docs/rules/no-proto.md
  45. +13 −4 docs/rules/no-redeclare.md
  46. +7 −1 docs/rules/no-regex-spaces.md
  47. +2 −0 docs/rules/no-reserved-keys.md
  48. +16 −16 docs/rules/no-restricted-modules.md
  49. +3 −3 docs/rules/no-restricted-syntax.md
  50. +13 −5 docs/rules/no-return-assign.md
  51. +3 −1 docs/rules/no-script-url.md
  52. +3 −1 docs/rules/no-self-compare.md
  53. +14 −10 docs/rules/no-sequences.md
  54. +8 −12 docs/rules/no-shadow-restricted-names.md
  55. +47 −20 docs/rules/no-shadow.md
  56. +1 −1 docs/rules/no-space-before-semi.md
  57. +6 −4 docs/rules/no-spaced-func.md
  58. +6 −2 docs/rules/no-sparse-arrays.md
  59. +6 −2 docs/rules/no-sync.md
  60. +7 −3 docs/rules/no-ternary.md
  61. +8 −14 docs/rules/no-this-before-super.md
  62. +12 −6 docs/rules/no-throw-literal.md
  63. +9 −3 docs/rules/no-trailing-spaces.md
  64. +6 −2 docs/rules/no-undef-init.md
  65. +14 −3 docs/rules/no-undef.md
  66. +8 −4 docs/rules/no-undefined.md
  67. +7 −3 docs/rules/no-underscore-dangle.md
  68. +6 −2 docs/rules/no-unexpected-multiline.md
  69. +6 −2 docs/rules/no-unneeded-ternary.md
  70. +9 −5 docs/rules/no-unreachable.md
  71. +5 −5 docs/rules/no-unused-expressions.md
  72. +35 −9 docs/rules/no-unused-vars.md
  73. +10 −6 docs/rules/no-use-before-define.md
  74. +15 −13 docs/rules/no-useless-call.md
  75. +9 −5 docs/rules/no-useless-concat.md
  76. +10 −6 docs/rules/no-var.md
  77. +8 −5 docs/rules/no-void.md
  78. +21 −34 docs/rules/no-warning-comments.md
  79. +3 −2 docs/rules/no-with.md
  80. +3 −3 docs/rules/no-wrap-func.md
  81. +22 −15 docs/rules/object-curly-spacing.md
  82. +9 −3 docs/rules/object-shorthand.md
  83. +54 −32 docs/rules/one-var.md
  84. +14 −6 docs/rules/operator-assignment.md
  85. +25 −28 docs/rules/operator-linebreak.md
  86. +22 −14 docs/rules/padded-blocks.md
  87. +6 −2 docs/rules/prefer-arrow-callback.md
  88. +14 −14 docs/rules/prefer-const.md
  89. +88 −83 docs/rules/prefer-reflect.md
  90. +10 −10 docs/rules/prefer-spread.md
  91. +6 −2 docs/rules/prefer-template.md
  92. +49 −25 docs/rules/quote-props.md
  93. +61 −30 docs/rules/quotes.md
  94. +6 −2 docs/rules/radix.md
  95. +5 −5 docs/rules/require-yield.md
  96. +21 −13 docs/rules/semi-spacing.md
  97. +16 −6 docs/rules/semi.md
  98. +16 −8 docs/rules/sort-vars.md
  99. +12 −12 docs/rules/space-after-keywords.md
  100. +17 −9 docs/rules/space-before-blocks.md
  101. +34 −18 docs/rules/space-before-function-paren.md
  102. +4 −4 docs/rules/space-before-function-parentheses.md
  103. +7 −5 docs/rules/space-before-keywords.md
  104. +4 −4 docs/rules/space-in-brackets.md
  105. +71 −27 docs/rules/space-in-parens.md
  106. +25 −43 docs/rules/space-infix-ops.md
  107. +7 −11 docs/rules/space-return-throw-case.md
  108. +55 −82 docs/rules/space-unary-ops.md
  109. +64 −65 docs/rules/spaced-comment.md
  110. +21 −21 docs/rules/strict.md
  111. +6 −2 docs/rules/use-isnan.md
  112. +27 −6 docs/rules/valid-jsdoc.md
  113. +8 −6 docs/rules/valid-typeof.md
  114. +24 −33 docs/rules/vars-on-top.md
  115. +34 −16 docs/rules/wrap-iife.md
  116. +6 −2 docs/rules/wrap-regex.md
  117. +19 −29 docs/rules/yoda.md
View
@@ -10,6 +10,9 @@ insert_final_newline = true
[docs/rules/linebreak-style.md]
end_of_line = disabled
-[docs/rules/indent.md]
+[{docs/rules/{indent.md,no-mixed-spaces-and-tabs.md}]
indent_style = disabled
indent_size = disabled
+
+[docs/rules/no-trailing-spaces.md]
+trim_trailing_whitespace = false
@@ -87,7 +87,7 @@ else { /*error Closing curly brace does not appear on the same line
}
```
-The following patterns adhere to one true brace style and do not cause warnings:
+The following patterns adhere to one true brace style and are not considered warnings:
```js
/*eslint brace-style: 2*/
@@ -164,7 +164,7 @@ if (foo) {
}
```
-The following patterns adhere to Stroustrup style and do not cause warnings:
+The following patterns adhere to Stroustrup style and are not considered warnings:
```js
/*eslint brace-style: [2, "stroustrup"]*/
@@ -243,7 +243,7 @@ if (foo) { /*error Opening curly brace appears on the same line as con
}
```
-The following patterns adhere to Allman style and do not cause warnings:
+The following patterns adhere to Allman style and are not considered warnings:
```js
/*eslint brace-style: [2, "allman"]*/
@@ -53,7 +53,7 @@ The following patterns are considered warnings:
var foo = function() { /*error Expected a function declaration.*/
// ...
-} ;
+};
```
```js
@@ -69,16 +69,20 @@ The following patterns are not considered warnings:
```js
/*eslint func-style: [2, "declaration"]*/
+function foo() {
+ // ...
+}
+
+// Methods (functions assigned to objects) are not checked by this rule
SomeObject.foo = function() {
// ...
};
```
-
```js
/*eslint func-style: [2, "expression"]*/
-SomeObject.foo = function() {
+var foo = function() {
// ...
};
```
@@ -18,7 +18,7 @@ The following patterns are considered warnings:
function bar() { return /=foo/; } /*error A regular expression literal can be confused with '/='.*/
```
-The following patterns adhere to this rule:
+The following patterns are not considered warnings:
```js
/*eslint no-div-regex: 2*/
@@ -18,19 +18,19 @@ The following patterns are considered warnings:
```js
/*eslint no-dupe-keys: 2*/
-var foo = { /*error Duplicate key 'bar'.*/
+var foo = {
bar: "baz",
- bar: "qux"
+ bar: "qux" /*error Duplicate key 'bar'.*/
};
-var foo = { /*error Duplicate key 'bar'.*/
+var foo = {
"bar": "baz",
- bar: "qux"
+ bar: "qux" /*error Duplicate key 'bar'.*/
};
-var foo = { /*error Duplicate key '1'.*/
+var foo = {
0x1: "baz",
- 1: "qux"
+ 1: "qux" /*error Duplicate key '1'.*/
};
```
@@ -12,7 +12,7 @@ The following patterns are considered warnings:
```js
/*eslint no-empty-label: 2*/
-labeled: /*error Unexpected label labeled*/
+labeled: /*error Unexpected label "labeled"*/
var x = 10;
```
@@ -65,8 +65,10 @@ This rule is aimed at eliminating unintentional fallthrough of one case to the o
The following patterns are considered warnings:
```js
+/*eslint no-fallthrough: 2*/
+
switch(foo) {
- case 1:
+ case 1: /*error Expected a "break" statement before "case".*/
doSomething();
case 2:
@@ -77,6 +79,8 @@ switch(foo) {
The following patterns are considered okay and do not cause warnings:
```js
+/*eslint no-fallthrough: 2*/
+
switch(foo) {
case 1:
doSomething();
@@ -86,13 +90,15 @@ switch(foo) {
doSomething();
}
-switch(foo) {
- case 1:
- doSomething();
- return;
+function bar(foo) {
+ switch(foo) {
+ case 1:
+ doSomething();
+ return;
- case 2:
- doSomething();
+ case 2:
+ doSomething();
+ }
}
switch(foo) {
@@ -17,14 +17,18 @@ This rule is aimed at eliminating floating decimal points and will warn whenever
The following patterns are considered warnings:
```js
-var num = .5;
-var num = 2.;
-var num = -.7;
+/*eslint no-floating-decimal: 2*/
+
+var num = .5; /*error A leading decimal point can be confused with a dot.*/
+var num = 2.; /*error A trailing decimal point can be confused with a dot.*/
+var num = -.7; /*error A leading decimal point can be confused with a dot.*/
```
The following patterns are not considered warnings:
```js
+/*eslint no-floating-decimal: 2*/
+
var num = 0.5;
var num = 2.0;
```
@@ -14,24 +14,30 @@ This rule is aimed at flagging probable mistakes and issues in the form of overw
The following patterns are considered warnings:
```js
+/*eslint no-func-assign: 2*/
+
function foo() {}
-foo = bar;
+foo = bar; /*error 'foo' is a function.*/
function foo() {
- foo = bar;
+ foo = bar; /*error 'foo' is a function.*/
}
```
Unlike the same rule in JSHint, the following pattern is also considered a warning:
```js
-foo = bar;
+/*eslint no-func-assign: 2*/
+
+foo = bar; /*error 'foo' is a function.*/
function foo() {}
```
The following patterns are not considered warnings:
```js
+/*eslint no-func-assign: 2*/
+
var foo = function () {}
foo = bar;
@@ -48,13 +48,19 @@ This rule has three options.
The following patterns are considered warnings:
```js
-var b = !!foo;
-var b = ~foo.indexOf("."); // only with `indexOf`/`lastIndexOf` method calling.
+/*eslint no-implicit-coercion: 2*/
+
+var b = !!foo; /*error use `Boolean(foo)` instead.*/
+var b = ~foo.indexOf("."); /*error use `foo.indexOf(".") !== -1` instead.*/
+// only with `indexOf`/`lastIndexOf` method calling.
+
```
The following patterns are not considered warnings:
```js
+/*eslint no-implicit-coercion: 2*/
+
var b = Boolean(foo);
var b = foo.indexOf(".") !== -1;
@@ -66,13 +72,17 @@ var n = ~foo; // This is a just binary negating.
The following patterns are considered warnings:
```js
-var n = +foo;
-var n = 1 * foo;
+/*eslint no-implicit-coercion: 2*/
+
+var n = +foo; /*error use `Number(foo)` instead.*/
+var n = 1 * foo; /*error use `Number(foo)` instead.*/
```
The following patterns are not considered warnings:
```js
+/*eslint no-implicit-coercion: 2*/
+
var b = Number(foo);
var b = parseFloat(foo);
var b = parseInt(foo, 10);
@@ -83,12 +93,16 @@ var b = parseInt(foo, 10);
The following patterns are considered warnings:
```js
-var n = "" + foo;
+/*eslint no-implicit-coercion: 2*/
+
+var n = "" + foo; /*error use `String(foo)` instead.*/
```
The following patterns are not considered warnings:
```js
+/*eslint no-implicit-coercion: 2*/
+
var b = String(foo);
```
@@ -27,20 +27,24 @@ This rule aims to eliminate implied `eval()` through the use of `setTimeout()`,
The following patterns are considered warnings:
```js
-setTimeout("alert('Hi!');", 100);
+/*eslint no-implied-eval: 2*/
+
+setTimeout("alert('Hi!');", 100); /*error Implied eval. Consider passing a function instead of a string.*/
-setInterval("alert('Hi!');", 100);
+setInterval("alert('Hi!');", 100); /*error Implied eval. Consider passing a function instead of a string.*/
-execScript("alert('Hi!')");
+execScript("alert('Hi!')"); /*error Implied eval. Consider passing a function instead of a string.*/
-window.setTimeout("count = 5", 10);
+window.setTimeout("count = 5", 10); /*error Implied eval. Consider passing a function instead of a string.*/
-window.setInterval("foo = bar", 10);
+window.setInterval("foo = bar", 10); /*error Implied eval. Consider passing a function instead of a string.*/
```
The following patterns are not warnings:
```js
+/*eslint no-implied-eval: 2*/
+
setTimeout(function() {
alert("Hi!");
}, 100);
@@ -14,32 +14,28 @@ This rule takes no arguments.
The following patterns are considered warnings:
```js
-var a = 1; // declaring a to 1
-```
+/*eslint no-inline-comments: 2*/
+
+var a = 1; // declaring a to 1 /*error Unexpected comment inline with code.*/
-```js
function getRandomNumber(){
-return 4; // chosen by fair dice roll.
- // guaranteed to be random.
+ return 4; // chosen by fair dice roll. /*error Unexpected comment inline with code.*/
+ // guaranteed to be random.
}
-```
-```js
-/* A block comment before code */ var a = 2;
-```
+/* A block comment before code */ var b = 2; /*error Unexpected comment inline with code.*/
-```js
-var a = 3; /* A block comment after code */
+var c = 3; /* A block comment after code */ /*error Unexpected comment inline with code.*/
```
The following patterns are not warnings:
```js
+/*eslint no-inline-comments: 2*/
+
// This is a comment above a line of code
var foo = 5;
-```
-```js
-var foo = 5;
+var bar = 5;
//This is a comment below a line of code
```
Oops, something went wrong.

0 comments on commit 850f0cc

Please sign in to comment.