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.
Files changed (49) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/bin/eslint.js +2 -1
  3. package/conf/eslint-recommended.js +1 -0
  4. package/lib/ast-utils.js +20 -17
  5. package/lib/cli-engine.js +51 -124
  6. package/lib/code-path-analysis/code-path-analyzer.js +8 -4
  7. package/lib/code-path-analysis/code-path-segment.js +2 -1
  8. package/lib/code-path-analysis/code-path-state.js +21 -14
  9. package/lib/code-path-analysis/code-path.js +3 -2
  10. package/lib/code-path-analysis/fork-context.js +2 -1
  11. package/lib/config/autoconfig.js +2 -4
  12. package/lib/config/config-initializer.js +9 -5
  13. package/lib/config/config-ops.js +15 -15
  14. package/lib/config.js +8 -12
  15. package/lib/formatters/codeframe.js +1 -1
  16. package/lib/formatters/stylish.js +1 -1
  17. package/lib/ignored-paths.js +0 -2
  18. package/lib/linter.js +468 -638
  19. package/lib/report-translator.js +274 -0
  20. package/lib/rules/function-paren-newline.js +221 -0
  21. package/lib/rules/generator-star-spacing.js +70 -19
  22. package/lib/rules/indent-legacy.js +3 -2
  23. package/lib/rules/indent.js +15 -6
  24. package/lib/rules/key-spacing.js +2 -1
  25. package/lib/rules/newline-per-chained-call.js +20 -3
  26. package/lib/rules/no-extra-parens.js +75 -33
  27. package/lib/rules/no-invalid-this.js +2 -1
  28. package/lib/rules/no-tabs.js +1 -1
  29. package/lib/rules/no-undef-init.js +4 -0
  30. package/lib/rules/no-unmodified-loop-condition.js +1 -1
  31. package/lib/rules/no-unused-vars.js +47 -4
  32. package/lib/rules/padded-blocks.js +2 -2
  33. package/lib/rules/prefer-arrow-callback.js +1 -2
  34. package/lib/rules/quote-props.js +4 -2
  35. package/lib/rules/quotes.js +1 -2
  36. package/lib/rules/space-before-blocks.js +1 -1
  37. package/lib/rules/valid-jsdoc.js +2 -2
  38. package/lib/rules.js +48 -3
  39. package/lib/testers/rule-tester.js +27 -51
  40. package/lib/timing.js +2 -2
  41. package/lib/util/apply-disable-directives.js +131 -0
  42. package/lib/util/fix-tracker.js +1 -2
  43. package/lib/util/npm-util.js +21 -4
  44. package/lib/util/source-code-fixer.js +5 -14
  45. package/lib/util/source-code.js +3 -5
  46. package/package.json +8 -8
  47. package/lib/rule-context.js +0 -241
  48. package/lib/testers/event-generator-tester.js +0 -62
  49. 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
- };