eslint 4.5.0 → 4.7.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.
- package/CHANGELOG.md +98 -0
- package/bin/eslint.js +2 -1
- package/conf/eslint-recommended.js +1 -0
- package/lib/ast-utils.js +20 -17
- package/lib/cli-engine.js +51 -124
- package/lib/code-path-analysis/code-path-analyzer.js +8 -4
- package/lib/code-path-analysis/code-path-segment.js +2 -1
- package/lib/code-path-analysis/code-path-state.js +21 -14
- package/lib/code-path-analysis/code-path.js +3 -2
- package/lib/code-path-analysis/fork-context.js +2 -1
- package/lib/config/autoconfig.js +2 -4
- package/lib/config/config-initializer.js +9 -5
- package/lib/config/config-ops.js +15 -15
- package/lib/config.js +8 -12
- package/lib/formatters/codeframe.js +1 -1
- package/lib/formatters/stylish.js +1 -1
- package/lib/ignored-paths.js +0 -2
- package/lib/linter.js +468 -638
- package/lib/report-translator.js +274 -0
- package/lib/rules/function-paren-newline.js +221 -0
- package/lib/rules/generator-star-spacing.js +70 -19
- package/lib/rules/indent-legacy.js +3 -2
- package/lib/rules/indent.js +15 -6
- package/lib/rules/key-spacing.js +2 -1
- package/lib/rules/newline-per-chained-call.js +20 -3
- package/lib/rules/no-extra-parens.js +75 -33
- package/lib/rules/no-invalid-this.js +2 -1
- package/lib/rules/no-tabs.js +1 -1
- package/lib/rules/no-undef-init.js +4 -0
- package/lib/rules/no-unmodified-loop-condition.js +1 -1
- package/lib/rules/no-unused-vars.js +47 -4
- package/lib/rules/padded-blocks.js +2 -2
- package/lib/rules/prefer-arrow-callback.js +1 -2
- package/lib/rules/quote-props.js +4 -2
- package/lib/rules/quotes.js +1 -2
- package/lib/rules/space-before-blocks.js +1 -1
- package/lib/rules/valid-jsdoc.js +2 -2
- package/lib/rules.js +48 -3
- package/lib/testers/rule-tester.js +27 -51
- package/lib/timing.js +2 -2
- package/lib/util/apply-disable-directives.js +131 -0
- package/lib/util/fix-tracker.js +1 -2
- package/lib/util/npm-util.js +21 -4
- package/lib/util/source-code-fixer.js +5 -14
- package/lib/util/source-code.js +3 -5
- package/package.json +8 -8
- package/lib/rule-context.js +0 -241
- package/lib/testers/event-generator-tester.js +0 -62
- package/lib/testers/test-parser.js +0 -48
@@ -1,62 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @fileoverview Helpers to test EventGenerator interface.
|
3
|
-
* @author Toru Nagashima
|
4
|
-
*/
|
5
|
-
"use strict";
|
6
|
-
|
7
|
-
/* global describe, it */
|
8
|
-
|
9
|
-
//------------------------------------------------------------------------------
|
10
|
-
// Requirements
|
11
|
-
//------------------------------------------------------------------------------
|
12
|
-
|
13
|
-
const assert = require("assert");
|
14
|
-
|
15
|
-
//------------------------------------------------------------------------------
|
16
|
-
// Public Interface
|
17
|
-
//------------------------------------------------------------------------------
|
18
|
-
|
19
|
-
module.exports = {
|
20
|
-
|
21
|
-
/**
|
22
|
-
* Overrideable `describe` function to test.
|
23
|
-
* @param {string} text - A description.
|
24
|
-
* @param {Function} method - A test logic.
|
25
|
-
* @returns {any} The returned value with the test logic.
|
26
|
-
*/
|
27
|
-
describe: (typeof describe === "function") ? describe : /* istanbul ignore next */ function(text, method) {
|
28
|
-
return method.apply(this);
|
29
|
-
},
|
30
|
-
|
31
|
-
/**
|
32
|
-
* Overrideable `it` function to test.
|
33
|
-
* @param {string} text - A description.
|
34
|
-
* @param {Function} method - A test logic.
|
35
|
-
* @returns {any} The returned value with the test logic.
|
36
|
-
*/
|
37
|
-
it: (typeof it === "function") ? it : /* istanbul ignore next */ function(text, method) {
|
38
|
-
return method.apply(this);
|
39
|
-
},
|
40
|
-
|
41
|
-
/**
|
42
|
-
* Does some tests to check a given object implements the EventGenerator interface.
|
43
|
-
* @param {Object} instance - An object to check.
|
44
|
-
* @returns {void}
|
45
|
-
*/
|
46
|
-
testEventGeneratorInterface(instance) {
|
47
|
-
this.describe("should implement EventGenerator interface", () => {
|
48
|
-
this.it("should have `emitter` property.", () => {
|
49
|
-
assert.equal(typeof instance.emitter, "object");
|
50
|
-
assert.equal(typeof instance.emitter.emit, "function");
|
51
|
-
});
|
52
|
-
|
53
|
-
this.it("should have `enterNode` property.", () => {
|
54
|
-
assert.equal(typeof instance.enterNode, "function");
|
55
|
-
});
|
56
|
-
|
57
|
-
this.it("should have `leaveNode` property.", () => {
|
58
|
-
assert.equal(typeof instance.leaveNode, "function");
|
59
|
-
});
|
60
|
-
});
|
61
|
-
}
|
62
|
-
};
|
@@ -1,48 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @author Toru Nagashima <https://github.com/mysticatea>
|
3
|
-
*/
|
4
|
-
"use strict";
|
5
|
-
|
6
|
-
const espree = require("espree");
|
7
|
-
const Traverser = require("../util/traverser");
|
8
|
-
|
9
|
-
/**
|
10
|
-
* Define `start`/`end` properties as throwing error.
|
11
|
-
* @param {ASTNode} node The node to define.
|
12
|
-
* @returns {void}
|
13
|
-
*/
|
14
|
-
function defineStartEndAsError(node) {
|
15
|
-
Object.defineProperty(node, "start", {
|
16
|
-
get() {
|
17
|
-
throw new Error("Use node.range[0] instead of node.start");
|
18
|
-
},
|
19
|
-
configurable: true,
|
20
|
-
enumerable: false
|
21
|
-
});
|
22
|
-
Object.defineProperty(node, "end", {
|
23
|
-
get() {
|
24
|
-
throw new Error("Use node.range[1] instead of node.end");
|
25
|
-
},
|
26
|
-
configurable: true,
|
27
|
-
enumerable: false
|
28
|
-
});
|
29
|
-
}
|
30
|
-
|
31
|
-
/**
|
32
|
-
* Define `start`/`end` properties of all nodes of the given AST as throwing error.
|
33
|
-
* @param {ASTNode} ast The root node to errorize `start`/`end` properties.
|
34
|
-
* @returns {void}
|
35
|
-
*/
|
36
|
-
function defineStartEndAsErrorInTree(ast) {
|
37
|
-
new Traverser().traverse(ast, { enter: defineStartEndAsError });
|
38
|
-
ast.tokens.forEach(defineStartEndAsError);
|
39
|
-
ast.comments.forEach(defineStartEndAsError);
|
40
|
-
}
|
41
|
-
|
42
|
-
module.exports.parse = (code, options) => {
|
43
|
-
const ret = espree.parse(code, options);
|
44
|
-
|
45
|
-
defineStartEndAsErrorInTree(ret.ast || ret);
|
46
|
-
|
47
|
-
return ret;
|
48
|
-
};
|