eslint 3.13.1 → 3.16.0
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.
- package/CHANGELOG.md +81 -0
- package/README.md +1 -1
- package/conf/{eslint.json → eslint-recommended.js} +88 -71
- package/lib/ast-utils.js +247 -28
- package/lib/cli.js +2 -2
- package/lib/code-path-analysis/code-path-state.js +2 -2
- package/lib/config/autoconfig.js +24 -20
- package/lib/config/config-file.js +31 -24
- package/lib/config/config-initializer.js +2 -2
- package/lib/config/config-rule.js +15 -16
- package/lib/config/config-validator.js +6 -6
- package/lib/config.js +3 -2
- package/lib/eslint.js +18 -18
- package/lib/formatters/checkstyle.js +2 -2
- package/lib/formatters/codeframe.js +1 -1
- package/lib/formatters/compact.js +2 -2
- package/lib/formatters/junit.js +2 -2
- package/lib/formatters/tap.js +2 -2
- package/lib/formatters/unix.js +2 -2
- package/lib/formatters/visualstudio.js +2 -2
- package/lib/internal-rules/internal-consistent-docs-description.js +1 -1
- package/lib/rule-context.js +2 -2
- package/lib/rules/arrow-body-style.js +7 -4
- package/lib/rules/arrow-spacing.js +7 -6
- package/lib/rules/block-spacing.js +2 -2
- package/lib/rules/brace-style.js +93 -202
- package/lib/rules/capitalized-comments.js +6 -6
- package/lib/rules/comma-dangle.js +6 -6
- package/lib/rules/comma-spacing.js +16 -16
- package/lib/rules/comma-style.js +1 -1
- package/lib/rules/consistent-return.js +1 -1
- package/lib/rules/constructor-super.js +3 -3
- package/lib/rules/curly.js +11 -7
- package/lib/rules/default-case.js +3 -3
- package/lib/rules/eqeqeq.js +15 -6
- package/lib/rules/func-call-spacing.js +12 -15
- package/lib/rules/func-name-matching.js +1 -1
- package/lib/rules/generator-star-spacing.js +18 -19
- package/lib/rules/global-require.js +2 -2
- package/lib/rules/id-blacklist.js +2 -2
- package/lib/rules/id-length.js +3 -3
- package/lib/rules/id-match.js +2 -2
- package/lib/rules/indent.js +21 -20
- package/lib/rules/key-spacing.js +20 -23
- package/lib/rules/keyword-spacing.js +2 -13
- package/lib/rules/line-comment-position.js +1 -1
- package/lib/rules/linebreak-style.js +7 -1
- package/lib/rules/lines-around-comment.js +4 -4
- package/lib/rules/lines-around-directive.js +4 -4
- package/lib/rules/max-lines.js +3 -3
- package/lib/rules/max-statements-per-line.js +8 -7
- package/lib/rules/new-cap.js +2 -2
- package/lib/rules/newline-after-var.js +7 -2
- package/lib/rules/newline-before-return.js +2 -2
- package/lib/rules/newline-per-chained-call.js +3 -1
- package/lib/rules/no-await-in-loop.js +5 -5
- package/lib/rules/no-cond-assign.js +3 -3
- package/lib/rules/no-dupe-keys.js +1 -1
- package/lib/rules/no-else-return.js +88 -25
- package/lib/rules/no-extend-native.js +3 -3
- package/lib/rules/no-extra-bind.js +3 -4
- package/lib/rules/no-extra-boolean-cast.js +22 -1
- package/lib/rules/no-extra-parens.js +57 -9
- package/lib/rules/no-inner-declarations.js +4 -4
- package/lib/rules/no-irregular-whitespace.js +7 -1
- package/lib/rules/no-lone-blocks.js +10 -10
- package/lib/rules/no-mixed-operators.js +1 -7
- package/lib/rules/no-mixed-requires.js +4 -4
- package/lib/rules/no-multi-assign.js +41 -0
- package/lib/rules/no-multi-spaces.js +4 -1
- package/lib/rules/no-multi-str.js +7 -3
- package/lib/rules/no-redeclare.js +7 -7
- package/lib/rules/no-return-assign.js +7 -14
- package/lib/rules/no-return-await.js +2 -2
- package/lib/rules/no-sequences.js +7 -6
- package/lib/rules/no-throw-literal.js +2 -39
- package/lib/rules/no-trailing-spaces.js +8 -2
- package/lib/rules/no-undefined.js +45 -6
- package/lib/rules/no-unexpected-multiline.js +9 -8
- package/lib/rules/no-unneeded-ternary.js +5 -1
- package/lib/rules/no-unused-labels.js +17 -2
- package/lib/rules/no-unused-vars.js +34 -19
- package/lib/rules/no-use-before-define.js +33 -29
- package/lib/rules/no-useless-computed-key.js +9 -4
- package/lib/rules/no-useless-concat.js +10 -7
- package/lib/rules/no-useless-escape.js +1 -1
- package/lib/rules/no-useless-return.js +5 -11
- package/lib/rules/no-var.js +69 -3
- package/lib/rules/no-whitespace-before-property.js +5 -16
- package/lib/rules/object-curly-newline.js +2 -2
- package/lib/rules/object-curly-spacing.js +7 -25
- package/lib/rules/object-property-newline.js +3 -3
- package/lib/rules/object-shorthand.js +10 -10
- package/lib/rules/operator-assignment.js +2 -2
- package/lib/rules/operator-linebreak.js +8 -10
- package/lib/rules/padded-blocks.js +4 -4
- package/lib/rules/prefer-promise-reject-errors.js +124 -0
- package/lib/rules/prefer-spread.js +1 -1
- package/lib/rules/prefer-template.js +1 -1
- package/lib/rules/quotes.js +11 -7
- package/lib/rules/require-await.js +1 -1
- package/lib/rules/semi-spacing.js +4 -0
- package/lib/rules/sort-imports.js +4 -4
- package/lib/rules/sort-keys.js +2 -2
- package/lib/rules/sort-vars.js +2 -2
- package/lib/rules/space-before-function-paren.js +9 -6
- package/lib/rules/space-in-parens.js +8 -8
- package/lib/rules/spaced-comment.js +10 -10
- package/lib/rules/strict.js +2 -2
- package/lib/rules/template-tag-spacing.js +77 -0
- package/lib/rules/unicode-bom.js +1 -1
- package/lib/rules/wrap-iife.js +5 -5
- package/lib/rules/yoda.js +2 -7
- package/lib/rules.js +2 -2
- package/lib/testers/rule-tester.js +28 -21
- package/lib/token-store/backward-token-comment-cursor.js +57 -0
- package/lib/token-store/backward-token-cursor.js +56 -0
- package/lib/token-store/cursor.js +76 -0
- package/lib/token-store/cursors.js +92 -0
- package/lib/token-store/decorative-cursor.js +39 -0
- package/lib/token-store/filter-cursor.js +43 -0
- package/lib/token-store/forward-token-comment-cursor.js +57 -0
- package/lib/token-store/forward-token-cursor.js +61 -0
- package/lib/token-store/index.js +604 -0
- package/lib/token-store/limit-cursor.js +40 -0
- package/lib/token-store/padded-token-cursor.js +38 -0
- package/lib/token-store/skip-cursor.js +42 -0
- package/lib/token-store/utils.js +100 -0
- package/lib/util/comment-event-generator.js +17 -16
- package/lib/util/glob-util.js +1 -1
- package/lib/util/glob.js +1 -1
- package/lib/util/rule-fixer.js +3 -8
- package/lib/util/source-code-fixer.js +41 -45
- package/lib/util/source-code.js +35 -19
- package/messages/extend-config-missing.txt +3 -0
- package/package.json +3 -3
- package/lib/token-store.js +0 -203
@@ -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
|
+
};
|