eslint 3.14.0 → 3.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +1 -1
  3. package/conf/{eslint.json → eslint-recommended.js} +86 -71
  4. package/lib/ast-utils.js +192 -24
  5. package/lib/cli.js +2 -2
  6. package/lib/code-path-analysis/code-path-state.js +2 -2
  7. package/lib/config/autoconfig.js +3 -3
  8. package/lib/config/config-file.js +31 -24
  9. package/lib/config/config-initializer.js +1 -1
  10. package/lib/config/config-validator.js +6 -6
  11. package/lib/config.js +3 -2
  12. package/lib/eslint.js +18 -18
  13. package/lib/formatters/checkstyle.js +2 -2
  14. package/lib/formatters/compact.js +2 -2
  15. package/lib/formatters/junit.js +2 -2
  16. package/lib/formatters/tap.js +2 -2
  17. package/lib/formatters/unix.js +2 -2
  18. package/lib/formatters/visualstudio.js +2 -2
  19. package/lib/rules/arrow-body-style.js +7 -4
  20. package/lib/rules/arrow-spacing.js +7 -6
  21. package/lib/rules/block-spacing.js +2 -2
  22. package/lib/rules/brace-style.js +42 -22
  23. package/lib/rules/capitalized-comments.js +6 -6
  24. package/lib/rules/comma-spacing.js +16 -16
  25. package/lib/rules/consistent-return.js +1 -1
  26. package/lib/rules/constructor-super.js +3 -3
  27. package/lib/rules/curly.js +11 -7
  28. package/lib/rules/default-case.js +3 -3
  29. package/lib/rules/eqeqeq.js +15 -6
  30. package/lib/rules/func-call-spacing.js +10 -13
  31. package/lib/rules/func-name-matching.js +1 -1
  32. package/lib/rules/generator-star-spacing.js +18 -19
  33. package/lib/rules/global-require.js +2 -2
  34. package/lib/rules/id-blacklist.js +2 -2
  35. package/lib/rules/id-length.js +3 -3
  36. package/lib/rules/id-match.js +2 -2
  37. package/lib/rules/indent.js +21 -20
  38. package/lib/rules/key-spacing.js +20 -23
  39. package/lib/rules/keyword-spacing.js +2 -13
  40. package/lib/rules/line-comment-position.js +1 -1
  41. package/lib/rules/linebreak-style.js +7 -1
  42. package/lib/rules/lines-around-comment.js +4 -4
  43. package/lib/rules/lines-around-directive.js +3 -3
  44. package/lib/rules/max-lines.js +2 -2
  45. package/lib/rules/max-statements-per-line.js +7 -6
  46. package/lib/rules/new-cap.js +2 -2
  47. package/lib/rules/newline-after-var.js +7 -2
  48. package/lib/rules/newline-before-return.js +2 -2
  49. package/lib/rules/newline-per-chained-call.js +3 -1
  50. package/lib/rules/no-cond-assign.js +3 -3
  51. package/lib/rules/no-extend-native.js +3 -3
  52. package/lib/rules/no-extra-bind.js +3 -4
  53. package/lib/rules/no-extra-boolean-cast.js +8 -0
  54. package/lib/rules/no-extra-parens.js +29 -8
  55. package/lib/rules/no-inner-declarations.js +4 -4
  56. package/lib/rules/no-irregular-whitespace.js +7 -1
  57. package/lib/rules/no-lone-blocks.js +10 -10
  58. package/lib/rules/no-mixed-operators.js +1 -7
  59. package/lib/rules/no-mixed-requires.js +4 -4
  60. package/lib/rules/no-multi-spaces.js +4 -1
  61. package/lib/rules/no-multi-str.js +7 -3
  62. package/lib/rules/no-redeclare.js +7 -7
  63. package/lib/rules/no-return-assign.js +7 -14
  64. package/lib/rules/no-sequences.js +7 -6
  65. package/lib/rules/no-trailing-spaces.js +8 -2
  66. package/lib/rules/no-undefined.js +45 -6
  67. package/lib/rules/no-unexpected-multiline.js +9 -8
  68. package/lib/rules/no-unneeded-ternary.js +5 -1
  69. package/lib/rules/no-unused-labels.js +17 -2
  70. package/lib/rules/no-unused-vars.js +34 -19
  71. package/lib/rules/no-use-before-define.js +33 -29
  72. package/lib/rules/no-useless-computed-key.js +8 -3
  73. package/lib/rules/no-useless-concat.js +10 -7
  74. package/lib/rules/no-useless-escape.js +1 -1
  75. package/lib/rules/no-useless-return.js +1 -7
  76. package/lib/rules/no-var.js +11 -0
  77. package/lib/rules/no-whitespace-before-property.js +5 -16
  78. package/lib/rules/object-curly-newline.js +2 -2
  79. package/lib/rules/object-curly-spacing.js +7 -25
  80. package/lib/rules/object-property-newline.js +3 -3
  81. package/lib/rules/object-shorthand.js +10 -10
  82. package/lib/rules/operator-assignment.js +2 -2
  83. package/lib/rules/operator-linebreak.js +8 -10
  84. package/lib/rules/padded-blocks.js +7 -4
  85. package/lib/rules/prefer-spread.js +1 -1
  86. package/lib/rules/prefer-template.js +1 -1
  87. package/lib/rules/quotes.js +10 -6
  88. package/lib/rules/semi-spacing.js +4 -0
  89. package/lib/rules/sort-imports.js +4 -4
  90. package/lib/rules/sort-vars.js +2 -2
  91. package/lib/rules/space-before-function-paren.js +8 -5
  92. package/lib/rules/space-in-parens.js +8 -8
  93. package/lib/rules/spaced-comment.js +10 -10
  94. package/lib/rules/strict.js +2 -2
  95. package/lib/rules/template-tag-spacing.js +77 -0
  96. package/lib/rules/unicode-bom.js +1 -1
  97. package/lib/rules/wrap-iife.js +5 -5
  98. package/lib/rules/yoda.js +2 -7
  99. package/lib/rules.js +2 -2
  100. package/lib/testers/rule-tester.js +25 -18
  101. package/lib/token-store/backward-token-comment-cursor.js +57 -0
  102. package/lib/token-store/backward-token-cursor.js +56 -0
  103. package/lib/token-store/cursor.js +76 -0
  104. package/lib/token-store/cursors.js +92 -0
  105. package/lib/token-store/decorative-cursor.js +39 -0
  106. package/lib/token-store/filter-cursor.js +43 -0
  107. package/lib/token-store/forward-token-comment-cursor.js +57 -0
  108. package/lib/token-store/forward-token-cursor.js +61 -0
  109. package/lib/token-store/index.js +604 -0
  110. package/lib/token-store/limit-cursor.js +40 -0
  111. package/lib/token-store/padded-token-cursor.js +38 -0
  112. package/lib/token-store/skip-cursor.js +42 -0
  113. package/lib/token-store/utils.js +100 -0
  114. package/lib/util/glob.js +1 -1
  115. package/lib/util/source-code-fixer.js +46 -44
  116. package/lib/util/source-code.js +35 -19
  117. package/messages/extend-config-missing.txt +3 -0
  118. package/package.json +3 -3
  119. package/lib/token-store.js +0 -203
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @fileoverview Define the cursor which ignores specified tokens.
3
+ * @author Toru Nagashima
4
+ */
5
+ "use strict";
6
+
7
+ //------------------------------------------------------------------------------
8
+ // Requirements
9
+ //------------------------------------------------------------------------------
10
+
11
+ const DecorativeCursor = require("./decorative-cursor");
12
+
13
+ //------------------------------------------------------------------------------
14
+ // Exports
15
+ //------------------------------------------------------------------------------
16
+
17
+ /**
18
+ * The decorative cursor which ignores specified tokens.
19
+ */
20
+ module.exports = class FilterCursor extends DecorativeCursor {
21
+
22
+ /**
23
+ * Initializes this cursor.
24
+ * @param {Cursor} cursor - The cursor to be decorated.
25
+ * @param {Function} predicate - The predicate function to decide tokens this cursor iterates.
26
+ */
27
+ constructor(cursor, predicate) {
28
+ super(cursor);
29
+ this.predicate = predicate;
30
+ }
31
+
32
+ /** @inheritdoc */
33
+ moveNext() {
34
+ const predicate = this.predicate;
35
+
36
+ while (super.moveNext()) {
37
+ if (predicate(this.current)) {
38
+ return true;
39
+ }
40
+ }
41
+ return false;
42
+ }
43
+ };
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @fileoverview Define the cursor which iterates tokens and comments.
3
+ * @author Toru Nagashima
4
+ */
5
+ "use strict";
6
+
7
+ //------------------------------------------------------------------------------
8
+ // Requirements
9
+ //------------------------------------------------------------------------------
10
+
11
+ const Cursor = require("./cursor");
12
+ const utils = require("./utils");
13
+
14
+ //------------------------------------------------------------------------------
15
+ // Exports
16
+ //------------------------------------------------------------------------------
17
+
18
+ /**
19
+ * The cursor which iterates tokens and comments.
20
+ */
21
+ module.exports = class ForwardTokenCommentCursor extends Cursor {
22
+
23
+ /**
24
+ * Initializes this cursor.
25
+ * @param {Token[]} tokens - The array of tokens.
26
+ * @param {Comment[]} comments - The array of comments.
27
+ * @param {Object} indexMap - The map from locations to indices in `tokens`.
28
+ * @param {number} startLoc - The start location of the iteration range.
29
+ * @param {number} endLoc - The end location of the iteration range.
30
+ */
31
+ constructor(tokens, comments, indexMap, startLoc, endLoc) {
32
+ super();
33
+ this.tokens = tokens;
34
+ this.comments = comments;
35
+ this.tokenIndex = utils.getFirstIndex(tokens, indexMap, startLoc);
36
+ this.commentIndex = utils.search(comments, startLoc);
37
+ this.border = endLoc;
38
+ }
39
+
40
+ /** @inheritdoc */
41
+ moveNext() {
42
+ const token = (this.tokenIndex < this.tokens.length) ? this.tokens[this.tokenIndex] : null;
43
+ const comment = (this.commentIndex < this.comments.length) ? this.comments[this.commentIndex] : null;
44
+
45
+ if (token && (!comment || token.range[0] < comment.range[0])) {
46
+ this.current = token;
47
+ this.tokenIndex += 1;
48
+ } else if (comment) {
49
+ this.current = comment;
50
+ this.commentIndex += 1;
51
+ } else {
52
+ this.current = null;
53
+ }
54
+
55
+ return Boolean(this.current) && (this.border === -1 || this.current.range[1] <= this.border);
56
+ }
57
+ };
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @fileoverview Define the cursor which iterates tokens only.
3
+ * @author Toru Nagashima
4
+ */
5
+ "use strict";
6
+
7
+ //------------------------------------------------------------------------------
8
+ // Requirements
9
+ //------------------------------------------------------------------------------
10
+
11
+ const Cursor = require("./cursor");
12
+ const utils = require("./utils");
13
+
14
+ //------------------------------------------------------------------------------
15
+ // Exports
16
+ //------------------------------------------------------------------------------
17
+
18
+ /**
19
+ * The cursor which iterates tokens only.
20
+ */
21
+ module.exports = class ForwardTokenCursor extends Cursor {
22
+
23
+ /**
24
+ * Initializes this cursor.
25
+ * @param {Token[]} tokens - The array of tokens.
26
+ * @param {Comment[]} comments - The array of comments.
27
+ * @param {Object} indexMap - The map from locations to indices in `tokens`.
28
+ * @param {number} startLoc - The start location of the iteration range.
29
+ * @param {number} endLoc - The end location of the iteration range.
30
+ */
31
+ constructor(tokens, comments, indexMap, startLoc, endLoc) {
32
+ super();
33
+ this.tokens = tokens;
34
+ this.index = utils.getFirstIndex(tokens, indexMap, startLoc);
35
+ this.indexEnd = utils.getLastIndex(tokens, indexMap, endLoc);
36
+ }
37
+
38
+ /** @inheritdoc */
39
+ moveNext() {
40
+ if (this.index <= this.indexEnd) {
41
+ this.current = this.tokens[this.index];
42
+ this.index += 1;
43
+ return true;
44
+ }
45
+ return false;
46
+ }
47
+
48
+ //
49
+ // Shorthand for performance.
50
+ //
51
+
52
+ /** @inheritdoc */
53
+ getOneToken() {
54
+ return (this.index <= this.indexEnd) ? this.tokens[this.index] : null;
55
+ }
56
+
57
+ /** @inheritdoc */
58
+ getAllTokens() {
59
+ return this.tokens.slice(this.index, this.indexEnd + 1);
60
+ }
61
+ };