eslint 3.9.0 → 3.10.2

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 (112) hide show
  1. package/CHANGELOG.md +60 -1
  2. package/LICENSE +1 -1
  3. package/README.md +1 -1
  4. package/bin/eslint.js +5 -5
  5. package/conf/eslint.json +1 -0
  6. package/lib/ast-utils.js +1 -3
  7. package/lib/cli-engine.js +9 -11
  8. package/lib/code-path-analysis/debug-helpers.js +4 -4
  9. package/lib/config/autoconfig.js +23 -35
  10. package/lib/config/config-file.js +1 -1
  11. package/lib/config/config-initializer.js +12 -20
  12. package/lib/config/config-ops.js +7 -9
  13. package/lib/config/config-rule.js +14 -18
  14. package/lib/config/config-validator.js +3 -3
  15. package/lib/config/environments.js +1 -1
  16. package/lib/config.js +2 -2
  17. package/lib/eslint.js +21 -23
  18. package/lib/file-finder.js +1 -1
  19. package/lib/formatters/checkstyle.js +2 -2
  20. package/lib/formatters/compact.js +2 -2
  21. package/lib/formatters/html.js +9 -11
  22. package/lib/formatters/jslint-xml.js +2 -2
  23. package/lib/formatters/junit.js +2 -2
  24. package/lib/formatters/stylish.js +3 -7
  25. package/lib/formatters/table.js +4 -6
  26. package/lib/formatters/tap.js +2 -2
  27. package/lib/formatters/unix.js +2 -2
  28. package/lib/formatters/visualstudio.js +2 -2
  29. package/lib/load-rules.js +1 -1
  30. package/lib/rules/arrow-body-style.js +1 -1
  31. package/lib/rules/arrow-parens.js +9 -2
  32. package/lib/rules/brace-style.js +2 -2
  33. package/lib/rules/comma-spacing.js +2 -2
  34. package/lib/rules/comma-style.js +51 -4
  35. package/lib/rules/consistent-this.js +5 -9
  36. package/lib/rules/constructor-super.js +1 -1
  37. package/lib/rules/curly.js +10 -7
  38. package/lib/rules/default-case.js +1 -3
  39. package/lib/rules/eqeqeq.js +19 -7
  40. package/lib/rules/func-names.js +23 -4
  41. package/lib/rules/global-require.js +3 -7
  42. package/lib/rules/handle-callback-err.js +1 -3
  43. package/lib/rules/id-length.js +1 -1
  44. package/lib/rules/indent.js +10 -25
  45. package/lib/rules/key-spacing.js +4 -4
  46. package/lib/rules/keyword-spacing.js +1 -1
  47. package/lib/rules/lines-around-comment.js +5 -11
  48. package/lib/rules/lines-around-directive.js +23 -4
  49. package/lib/rules/max-len.js +5 -11
  50. package/lib/rules/max-lines.js +4 -12
  51. package/lib/rules/max-statements.js +11 -2
  52. package/lib/rules/newline-after-var.js +1 -1
  53. package/lib/rules/newline-before-return.js +2 -4
  54. package/lib/rules/no-alert.js +2 -4
  55. package/lib/rules/no-class-assign.js +1 -1
  56. package/lib/rules/no-const-assign.js +1 -1
  57. package/lib/rules/no-control-regex.js +2 -2
  58. package/lib/rules/no-duplicate-case.js +1 -1
  59. package/lib/rules/no-ex-assign.js +1 -1
  60. package/lib/rules/no-extend-native.js +3 -7
  61. package/lib/rules/no-extra-boolean-cast.js +14 -3
  62. package/lib/rules/no-extra-parens.js +4 -4
  63. package/lib/rules/no-func-assign.js +1 -1
  64. package/lib/rules/no-implicit-globals.js +4 -4
  65. package/lib/rules/no-irregular-whitespace.js +3 -3
  66. package/lib/rules/no-mixed-operators.js +1 -3
  67. package/lib/rules/no-mixed-requires.js +2 -2
  68. package/lib/rules/no-mixed-spaces-and-tabs.js +3 -3
  69. package/lib/rules/no-multi-spaces.js +1 -1
  70. package/lib/rules/no-new-symbol.js +1 -1
  71. package/lib/rules/no-redeclare.js +2 -4
  72. package/lib/rules/no-restricted-globals.js +2 -2
  73. package/lib/rules/no-restricted-imports.js +45 -11
  74. package/lib/rules/no-restricted-modules.js +53 -36
  75. package/lib/rules/no-restricted-syntax.js +2 -4
  76. package/lib/rules/no-return-await.js +77 -0
  77. package/lib/rules/no-tabs.js +1 -1
  78. package/lib/rules/no-this-before-super.js +2 -2
  79. package/lib/rules/no-undef.js +1 -1
  80. package/lib/rules/no-underscore-dangle.js +1 -3
  81. package/lib/rules/no-unused-vars.js +2 -6
  82. package/lib/rules/no-use-before-define.js +1 -1
  83. package/lib/rules/no-useless-escape.js +8 -54
  84. package/lib/rules/no-useless-return.js +6 -0
  85. package/lib/rules/no-warning-comments.js +2 -2
  86. package/lib/rules/object-shorthand.js +21 -10
  87. package/lib/rules/one-var-declaration-per-line.js +1 -1
  88. package/lib/rules/prefer-const.js +1 -3
  89. package/lib/rules/prefer-reflect.js +2 -1
  90. package/lib/rules/quote-props.js +1 -1
  91. package/lib/rules/quotes.js +1 -1
  92. package/lib/rules/radix.js +2 -2
  93. package/lib/rules/require-jsdoc.js +8 -0
  94. package/lib/rules/sort-vars.js +1 -1
  95. package/lib/rules/space-in-parens.js +1 -1
  96. package/lib/rules/space-infix-ops.js +1 -1
  97. package/lib/rules/spaced-comment.js +1 -1
  98. package/lib/rules/symbol-description.js +1 -1
  99. package/lib/rules/valid-jsdoc.js +3 -3
  100. package/lib/rules.js +2 -2
  101. package/lib/testers/event-generator-tester.js +5 -5
  102. package/lib/testers/rule-tester.js +11 -13
  103. package/lib/timing.js +11 -13
  104. package/lib/util/comment-event-generator.js +1 -1
  105. package/lib/util/glob-util.js +3 -5
  106. package/lib/util/npm-util.js +1 -1
  107. package/lib/util/source-code-fixer.js +3 -5
  108. package/lib/util/source-code-util.js +4 -4
  109. package/lib/util/source-code.js +3 -3
  110. package/lib/util/traverser.js +1 -3
  111. package/lib/util/xml-escape.js +1 -1
  112. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,3 +1,62 @@
1
+ v3.10.2 - November 15, 2016
2
+
3
+ * 0643bfe Fix: correctly handle commented code in `indent` autofixer (fixes #7604) (#7606) (Teddy Katz)
4
+ * bd0514c Fix: syntax error after `key-spacing` autofix with comment (fixes #7603) (#7607) (Teddy Katz)
5
+ * f56c1ef Fix: `indent` crash on parenthesized global return values (fixes #7573) (#7596) (Teddy Katz)
6
+ * 100c6e1 Docs: Fix example for curly "multi-or-nest" option (#7597) (Will Chen)
7
+ * 6abb534 Docs: Update code of conduct link (#7599) (Nicholas C. Zakas)
8
+ * 8302cdb Docs: Update no-tabs to match existing standards & improve readbility (#7590) (Matt Stow)
9
+
10
+ v3.10.1 - November 14, 2016
11
+
12
+ * 8a0e92a Fix: handle try/catch correctly in `no-return-await` (fixes #7581) (#7582) (Teddy Katz)
13
+ * c4dd015 Fix: no-useless-return stack overflow on unreachable loops (fixes #7583) (#7584) (Teddy Katz)
14
+
15
+ v3.10.0 - November 11, 2016
16
+
17
+ * 7ee039b Update: Add comma-style options for calls, fns, imports (fixes #7470) (Max Englander)
18
+ * 670e060 Chore: make the `object-shorthand` tests more readable (#7580) (Teddy Katz)
19
+ * c3f4809 Update: Allow `func-names` to recognize inferred ES6 names (fixes #7235) (#7244) (Logan Smyth)
20
+ * b8d6e48 Fix: syntax errors created by `object-shorthand` autofix (fixes #7574) (#7575) (Teddy Katz)
21
+ * 1b3b65c Chore: ensure that files in tests/conf are linted (#7579) (Teddy Katz)
22
+ * 2bd1dd7 Update: avoid creating extra whitespace in `arrow-body-style` fixer (#7504) (Teddy Katz)
23
+ * 66fe9ff New: `no-return-await` rule. (fixes #7537) (#7547) (Jordan Harband)
24
+ * 759525e Chore: Use process.exitCode instead of process.exit() in bin/eslint.js (#7569) (Teddy Katz)
25
+ * 0d60db7 Fix: Curly rule doesn't account for leading comment (fixes #7538) (#7539) (Will Chen)
26
+ * 5003b1c Update: fix in/instanceof handling with `space-infix-ops` (fixes #7525) (#7552) (Teddy Katz)
27
+ * 3e6131e Docs: explain config option merging (#7499) (Danny Andrews)
28
+ * 1766524 Update: "Error type should be" assertion in rule-tester (fixes 6106) (#7550) (Frans Jaspers)
29
+ * 44eb274 Docs: Missing semicolon report was missing a comma (#7553) (James)
30
+ * 6dbda15 Docs: Document the optional defaults argument for RuleTester (#7548) (Teddy Katz)
31
+ * e117b80 Docs: typo fix (#7546) (oprogramador)
32
+ * 25e5613 Chore: Remove incorrect test from indent.js. (#7531) (Scott Stern)
33
+ * c0f4937 Fix: `arrow-parens` supports type annotations (fixes #7406) (#7436) (Toru Nagashima)
34
+ * a838b8e Docs: `func-name-matching`: update with “always”/“never” option (#7536) (Jordan Harband)
35
+ * 3c379ff Update: `no-restricted-{imports,modules}`: add “patterns” (fixes #6963) (#7433) (Jordan Harband)
36
+ * f5764ee Docs: Update example of results returned from `executeOnFiles` (#7362) (Simen Bekkhus)
37
+ * 4613ba0 Fix: Add support for escape char in JSX. (#7461) (Scott Stern)
38
+ * ea0970d Fix: `curly` false positive with no-semicolon style (#7509) (Teddy Katz)
39
+ * af1fde1 Update: fix `brace-style` false negative on multiline node (fixes #7493) (#7496) (Teddy Katz)
40
+ * 3798aea Update: max-statements to report function name (refs #7260) (#7399) (Nicholas C. Zakas)
41
+ * 0c215fa Update: Add `ArrowFunctionExpression` support to `require-jsdoc` rule (#7518) (Gyandeep Singh)
42
+ * 578c373 Build: handle deprecated rules with no 'replacedBy' (refs #7471) (#7494) (Vitor Balocco)
43
+ * a7f3976 Docs: Specify min ESLint version for new rule format (#7501) (cowchimp)
44
+ * 8a3e717 Update: Fix `lines-around-directive` semicolon handling (fixes #7450) (#7483) (Teddy Katz)
45
+ * e58cead Update: add a fixer for certain statically-verifiable `eqeqeq` cases (#7389) (Teddy Katz)
46
+ * 0dea0ac Chore: Add Node 7 to travis ci build (#7506) (Gyandeep Singh)
47
+ * 36338f0 Update: add fixer for `no-extra-boolean-cast` (#7387) (Teddy Katz)
48
+ * 183def6 Chore: enable `prefer-arrow-callback` on ESLint codebase (fixes #6407) (#7503) (Teddy Katz)
49
+ * 4f1fa67 Docs: Update copyright (#7497) (Nicholas C. Zakas)
50
+
51
+ v3.9.1 - October 31, 2016
52
+
53
+ * 2012258 Fix: incorrect `indent` check for array property access (fixes #7484) (#7485) (Teddy Katz)
54
+ * 8a71d4a Fix: `no-useless-return` false positive on conditionals (fixes #7477) (#7482) (Teddy Katz)
55
+ * 56a662b Fix: allow escaped backreferences in `no-useless-escape` (fixes #7472) (#7474) (Teddy Katz)
56
+ * fffdf13 Build: Fix prefer-reflect rule to not crash site gen build (#7471) (Ilya Volodin)
57
+ * 8ba68a3 Docs: Update broken link (#7490) (Devinsuit)
58
+ * 65231d8 Docs: add the "fixable" icon for `no-useless-return` (#7480) (Teddy Katz)
59
+
1
60
  v3.9.0 - October 28, 2016
2
61
 
3
62
  * d933516 New: `no-useless-return` rule (fixes #7309) (#7441) (Toru Nagashima)
@@ -16,7 +75,7 @@ v3.9.0 - October 28, 2016
16
75
  * 16367a8 Fix: Return statement spacing. Fix for indent rule. (fixes #7164) (#7197) (Imad Elyafi)
17
76
  * 3813988 Update: fix false negative of `no-extra-parens` (fixes #7122) (#7432) (Toru Nagashima)
18
77
  * 23062e2 Docs: Fix typo in no-unexpected-multiline (fixes #7442) (#7447) (Denis Sikuler)
19
- * d257428 Update: `func-name-matching`: add “nameMatches” option (fixes #7391) (#7428) (Jordan Harband)
78
+ * d257428 Update: `func-name-matching`: add “always”/“never” option (fixes #7391) (#7428) (Jordan Harband)
20
79
  * c710584 Fix: support for MemberExpression with function body. (#7400) (Scott Stern)
21
80
  * 2c8ed2d Build: ensure that all files are linted on bash (fixes #7426) (#7427) (Teddy Katz)
22
81
  * 18ff70f Chore: Enable `no-useless-escape` (#7403) (Vitor Balocco)
package/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
  ESLint
2
- Copyright jQuery Foundation and other contributors, https://jquery.org/
2
+ Copyright JS Foundation and other contributors, https://js.foundation
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
  [Rules](http://eslint.org/docs/rules/) |
14
14
  [Contributing](http://eslint.org/docs/developer-guide/contributing) |
15
15
  [Reporting Bugs](http://eslint.org/docs/developer-guide/contributing/reporting-bugs) |
16
- [Code of Conduct](https://jquery.org/conduct/) |
16
+ [Code of Conduct](https://js.foundation/conduct/) |
17
17
  [Twitter](https://twitter.com/geteslint) |
18
18
  [Mailing List](https://groups.google.com/group/eslint) |
19
19
  [Chat Room](https://gitter.im/eslint/eslint)
package/bin/eslint.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * @author Nicholas C. Zakas
6
6
  */
7
7
 
8
- /* eslint no-console:off, no-process-exit:off */
8
+ /* eslint no-console:off */
9
9
 
10
10
  "use strict";
11
11
 
@@ -36,7 +36,7 @@ const concat = require("concat-stream"),
36
36
  // Execution
37
37
  //------------------------------------------------------------------------------
38
38
 
39
- process.on("uncaughtException", function(err) {
39
+ process.once("uncaughtException", err => {
40
40
 
41
41
  // lazy load
42
42
  const lodash = require("lodash");
@@ -51,17 +51,17 @@ process.on("uncaughtException", function(err) {
51
51
  console.log(err.stack);
52
52
  }
53
53
 
54
- process.exit(1);
54
+ process.exitCode = 1;
55
55
  });
56
56
 
57
57
  if (useStdIn) {
58
- process.stdin.pipe(concat({ encoding: "string" }, function(text) {
58
+ process.stdin.pipe(concat({ encoding: "string" }, text => {
59
59
  process.exitCode = cli.execute(process.argv, text);
60
60
  }));
61
61
  } else if (init) {
62
62
  const configInit = require("../lib/config/config-initializer");
63
63
 
64
- configInit.initializeConfig(function(err) {
64
+ configInit.initializeConfig(err => {
65
65
  if (err) {
66
66
  process.exitCode = 1;
67
67
  console.error(err.message);
package/conf/eslint.json CHANGED
@@ -91,6 +91,7 @@
91
91
  "no-restricted-properties": "off",
92
92
  "no-restricted-syntax": "off",
93
93
  "no-return-assign": "off",
94
+ "no-return-await": "off",
94
95
  "no-script-url": "off",
95
96
  "no-self-assign": "error",
96
97
  "no-self-compare": "off",
package/lib/ast-utils.js CHANGED
@@ -176,9 +176,7 @@ function hasJSDocThisTag(node, sourceCode) {
176
176
  // because callbacks don't have its JSDoc comment.
177
177
  // e.g.
178
178
  // sinon.test(/* @this sinon.Sandbox */function() { this.spy(); });
179
- return sourceCode.getComments(node).leading.some(function(comment) {
180
- return thisTagPattern.test(comment.value);
181
- });
179
+ return sourceCode.getComments(node).leading.some(comment => thisTagPattern.test(comment.value));
182
180
  }
183
181
 
184
182
  /**
package/lib/cli-engine.js CHANGED
@@ -90,7 +90,7 @@ const debug = require("debug")("eslint:cli-engine");
90
90
  * @private
91
91
  */
92
92
  function calculateStatsPerFile(messages) {
93
- return messages.reduce(function(stat, message) {
93
+ return messages.reduce((stat, message) => {
94
94
  if (message.fatal || message.severity === 2) {
95
95
  stat.errorCount++;
96
96
  } else {
@@ -110,7 +110,7 @@ function calculateStatsPerFile(messages) {
110
110
  * @private
111
111
  */
112
112
  function calculateStatsPerRun(results) {
113
- return results.reduce(function(stat, result) {
113
+ return results.reduce((stat, result) => {
114
114
  stat.errorCount += result.errorCount;
115
115
  stat.warningCount += result.warningCount;
116
116
  return stat;
@@ -241,7 +241,7 @@ function processText(text, configHelper, filename, fix, allowInlineConfig) {
241
241
  const parsedBlocks = processor.preprocess(text, filename);
242
242
  const unprocessedMessages = [];
243
243
 
244
- parsedBlocks.forEach(function(block) {
244
+ parsedBlocks.forEach(block => {
245
245
  unprocessedMessages.push(eslint.verify(block, config, {
246
246
  filename,
247
247
  allowInlineConfig
@@ -466,15 +466,15 @@ function CLIEngine(options) {
466
466
  if (this.options.rulePaths) {
467
467
  const cwd = this.options.cwd;
468
468
 
469
- this.options.rulePaths.forEach(function(rulesdir) {
469
+ this.options.rulePaths.forEach(rulesdir => {
470
470
  debug(`Loading rules from ${rulesdir}`);
471
471
  rules.load(rulesdir, cwd);
472
472
  });
473
473
  }
474
474
 
475
- Object.keys(this.options.rules || {}).forEach(function(name) {
475
+ Object.keys(this.options.rules || {}).forEach(name => {
476
476
  validator.validateRuleOptions(name, this.options.rules[name], "CLI");
477
- }.bind(this));
477
+ });
478
478
  }
479
479
 
480
480
  /**
@@ -526,7 +526,7 @@ CLIEngine.getFormatter = function(format) {
526
526
  CLIEngine.getErrorResults = function(results) {
527
527
  const filtered = [];
528
528
 
529
- results.forEach(function(result) {
529
+ results.forEach(result => {
530
530
  const filteredMessages = result.messages.filter(isErrorMessage);
531
531
 
532
532
  if (filteredMessages.length > 0) {
@@ -549,9 +549,7 @@ CLIEngine.getErrorResults = function(results) {
549
549
  * @returns {void}
550
550
  */
551
551
  CLIEngine.outputFixes = function(report) {
552
- report.results.filter(function(result) {
553
- return result.hasOwnProperty("output");
554
- }).forEach(function(result) {
552
+ report.results.filter(result => result.hasOwnProperty("output")).forEach(result => {
555
553
  fs.writeFileSync(result.filePath, result.output);
556
554
  });
557
555
  };
@@ -708,7 +706,7 @@ CLIEngine.prototype = {
708
706
  patterns = this.resolveFileGlobPatterns(patterns);
709
707
  const fileList = globUtil.listFilesToProcess(patterns, options);
710
708
 
711
- fileList.forEach(function(fileInfo) {
709
+ fileList.forEach(fileInfo => {
712
710
  executeOnFile(fileInfo.filename, fileInfo.ignored);
713
711
  });
714
712
 
@@ -108,7 +108,7 @@ module.exports = {
108
108
  }
109
109
 
110
110
  if (segment.internal.nodes.length > 0) {
111
- text += segment.internal.nodes.map(function(node) {
111
+ text += segment.internal.nodes.map(node => {
112
112
  switch (node.type) {
113
113
  case "Identifier": return `${node.type} (${node.name})`;
114
114
  case "Literal": return `${node.type} (${node.value})`;
@@ -116,7 +116,7 @@ module.exports = {
116
116
  }
117
117
  }).join("\\n");
118
118
  } else if (segment.internal.exitNodes.length > 0) {
119
- text += segment.internal.exitNodes.map(function(node) {
119
+ text += segment.internal.exitNodes.map(node => {
120
120
  switch (node.type) {
121
121
  case "Identifier": return `${node.type}:exit (${node.name})`;
122
122
  case "Literal": return `${node.type}:exit (${node.value})`;
@@ -176,7 +176,7 @@ module.exports = {
176
176
  stack.push([nextSegment, 0]);
177
177
  }
178
178
 
179
- codePath.returnedSegments.forEach(function(finalSegment) {
179
+ codePath.returnedSegments.forEach(finalSegment => {
180
180
  if (lastId === finalSegment.id) {
181
181
  text += "->final";
182
182
  } else {
@@ -185,7 +185,7 @@ module.exports = {
185
185
  lastId = null;
186
186
  });
187
187
 
188
- codePath.thrownSegments.forEach(function(finalSegment) {
188
+ codePath.thrownSegments.forEach(finalSegment => {
189
189
  if (lastId === finalSegment.id) {
190
190
  text += "->thrown";
191
191
  } else {
@@ -49,14 +49,12 @@ const MAX_CONFIG_COMBINATIONS = 17, // 16 combinations + 1 for severity only
49
49
  * @returns {Object} registryItems for each rule in provided rulesConfig
50
50
  */
51
51
  function makeRegistryItems(rulesConfig) {
52
- return Object.keys(rulesConfig).reduce(function(accumulator, ruleId) {
53
- accumulator[ruleId] = rulesConfig[ruleId].map(function(config) {
54
- return {
55
- config,
56
- specificity: config.length || 1,
57
- errorCount: void 0
58
- };
59
- });
52
+ return Object.keys(rulesConfig).reduce((accumulator, ruleId) => {
53
+ accumulator[ruleId] = rulesConfig[ruleId].map(config => ({
54
+ config,
55
+ specificity: config.length || 1,
56
+ errorCount: void 0
57
+ }));
60
58
  return accumulator;
61
59
  }, {});
62
60
  }
@@ -173,10 +171,8 @@ Registry.prototype = {
173
171
  newRegistry = new Registry();
174
172
 
175
173
  newRegistry.rules = Object.assign({}, this.rules);
176
- ruleIds.forEach(function(ruleId) {
177
- const errorFreeItems = newRegistry.rules[ruleId].filter(function(registryItem) {
178
- return (registryItem.errorCount === 0);
179
- });
174
+ ruleIds.forEach(ruleId => {
175
+ const errorFreeItems = newRegistry.rules[ruleId].filter(registryItem => (registryItem.errorCount === 0));
180
176
 
181
177
  if (errorFreeItems.length > 0) {
182
178
  newRegistry.rules[ruleId] = errorFreeItems;
@@ -198,10 +194,8 @@ Registry.prototype = {
198
194
  newRegistry = new Registry();
199
195
 
200
196
  newRegistry.rules = Object.assign({}, this.rules);
201
- ruleIds.forEach(function(ruleId) {
202
- newRegistry.rules[ruleId] = newRegistry.rules[ruleId].filter(function(registryItem) {
203
- return (typeof registryItem.errorCount !== "undefined");
204
- });
197
+ ruleIds.forEach(ruleId => {
198
+ newRegistry.rules[ruleId] = newRegistry.rules[ruleId].filter(registryItem => (typeof registryItem.errorCount !== "undefined"));
205
199
  });
206
200
 
207
201
  return newRegistry;
@@ -218,15 +212,13 @@ Registry.prototype = {
218
212
  const ruleIds = Object.keys(this.rules),
219
213
  failingRegistry = new Registry();
220
214
 
221
- ruleIds.forEach(function(ruleId) {
222
- const failingConfigs = this.rules[ruleId].filter(function(registryItem) {
223
- return (registryItem.errorCount > 0);
224
- });
215
+ ruleIds.forEach(ruleId => {
216
+ const failingConfigs = this.rules[ruleId].filter(registryItem => (registryItem.errorCount > 0));
225
217
 
226
218
  if (failingConfigs && failingConfigs.length === this.rules[ruleId].length) {
227
219
  failingRegistry.rules[ruleId] = failingConfigs;
228
220
  }
229
- }.bind(this));
221
+ });
230
222
 
231
223
  return failingRegistry;
232
224
  },
@@ -241,11 +233,11 @@ Registry.prototype = {
241
233
  const ruleIds = Object.keys(this.rules),
242
234
  config = {rules: {}};
243
235
 
244
- ruleIds.forEach(function(ruleId) {
236
+ ruleIds.forEach(ruleId => {
245
237
  if (this.rules[ruleId].length === 1) {
246
238
  config.rules[ruleId] = this.rules[ruleId][0].config;
247
239
  }
248
- }.bind(this));
240
+ });
249
241
 
250
242
  return config;
251
243
  },
@@ -261,11 +253,9 @@ Registry.prototype = {
261
253
  newRegistry = new Registry();
262
254
 
263
255
  newRegistry.rules = Object.assign({}, this.rules);
264
- ruleIds.forEach(function(ruleId) {
265
- newRegistry.rules[ruleId] = this.rules[ruleId].filter(function(registryItem) {
266
- return (registryItem.specificity === specificity);
267
- });
268
- }.bind(this));
256
+ ruleIds.forEach(ruleId => {
257
+ newRegistry.rules[ruleId] = this.rules[ruleId].filter(registryItem => (registryItem.specificity === specificity));
258
+ });
269
259
 
270
260
  return newRegistry;
271
261
  },
@@ -294,16 +284,16 @@ Registry.prototype = {
294
284
  const filenames = Object.keys(sourceCodes);
295
285
  const totalFilesLinting = filenames.length * ruleSets.length;
296
286
 
297
- filenames.forEach(function(filename) {
287
+ filenames.forEach(filename => {
298
288
  debug(`Linting file: ${filename}`);
299
289
 
300
290
  ruleSetIdx = 0;
301
291
 
302
- ruleSets.forEach(function(ruleSet) {
292
+ ruleSets.forEach(ruleSet => {
303
293
  const lintConfig = Object.assign({}, config, {rules: ruleSet});
304
294
  const lintResults = eslint.verify(sourceCodes[filename], lintConfig);
305
295
 
306
- lintResults.forEach(function(result) {
296
+ lintResults.forEach(result => {
307
297
 
308
298
  // It is possible that the error is from a configuration comment
309
299
  // in a linted file, in which case there may not be a config
@@ -342,11 +332,9 @@ function extendFromRecommended(config) {
342
332
 
343
333
  ConfigOps.normalizeToStrings(newConfig);
344
334
 
345
- const recRules = Object.keys(recConfig.rules).filter(function(ruleId) {
346
- return ConfigOps.isErrorSeverity(recConfig.rules[ruleId]);
347
- });
335
+ const recRules = Object.keys(recConfig.rules).filter(ruleId => ConfigOps.isErrorSeverity(recConfig.rules[ruleId]));
348
336
 
349
- recRules.forEach(function(ruleId) {
337
+ recRules.forEach(ruleId => {
350
338
  if (lodash.isEqual(recConfig.rules[ruleId], newConfig.rules[ruleId])) {
351
339
  delete newConfig.rules[ruleId];
352
340
  }
@@ -359,7 +359,7 @@ function applyExtends(config, filePath, relativeTo) {
359
359
  }
360
360
 
361
361
  // Make the last element in an array take the highest precedence
362
- config = configExtends.reduceRight(function(previousValue, parentPath) {
362
+ config = configExtends.reduceRight((previousValue, parentPath) => {
363
363
 
364
364
  if (parentPath === "eslint:recommended") {
365
365
 
@@ -62,9 +62,7 @@ function installModules(config) {
62
62
 
63
63
  // Create a list of modules which should be installed based on config
64
64
  if (config.plugins) {
65
- modules = modules.concat(config.plugins.map(function(name) {
66
- return `eslint-plugin-${name}`;
67
- }));
65
+ modules = modules.concat(config.plugins.map(name => `eslint-plugin-${name}`));
68
66
  }
69
67
  if (config.extends && config.extends.indexOf("eslint:") === -1) {
70
68
  modules.push(`eslint-config-${config.extends}`);
@@ -81,7 +79,7 @@ function installModules(config) {
81
79
  const installStatus = npmUtil.checkDevDeps(modules);
82
80
 
83
81
  // Install packages which aren't already installed
84
- const modulesToInstall = Object.keys(installStatus).filter(function(module) {
82
+ const modulesToInstall = Object.keys(installStatus).filter(module => {
85
83
  const notInstalled = installStatus[module] === false;
86
84
 
87
85
  if (module === "eslint" && notInstalled) {
@@ -128,7 +126,7 @@ function configureRules(answers, config) {
128
126
  const patterns = answers.patterns.split(/[\s]+/);
129
127
 
130
128
  try {
131
- sourceCodes = getSourceCodeOfFiles(patterns, { baseConfig: newConfig, useEslintrc: false }, function(total) {
129
+ sourceCodes = getSourceCodeOfFiles(patterns, { baseConfig: newConfig, useEslintrc: false }, total => {
132
130
  bar.tick((BAR_SOURCE_CODE_TOTAL / total));
133
131
  });
134
132
  } catch (e) {
@@ -147,20 +145,18 @@ function configureRules(answers, config) {
147
145
  registry.populateFromCoreRules();
148
146
 
149
147
  // Lint all files with each rule config in the registry
150
- registry = registry.lintSourceCode(sourceCodes, newConfig, function(total) {
148
+ registry = registry.lintSourceCode(sourceCodes, newConfig, total => {
151
149
  bar.tick((BAR_TOTAL - BAR_SOURCE_CODE_TOTAL) / total); // Subtract out ticks used at beginning
152
150
  });
153
151
  debug(`\nRegistry: ${util.inspect(registry.rules, {depth: null})}`);
154
152
 
155
153
  // Create a list of recommended rules, because we don't want to disable them
156
- const recRules = Object.keys(recConfig.rules).filter(function(ruleId) {
157
- return ConfigOps.isErrorSeverity(recConfig.rules[ruleId]);
158
- });
154
+ const recRules = Object.keys(recConfig.rules).filter(ruleId => ConfigOps.isErrorSeverity(recConfig.rules[ruleId]));
159
155
 
160
156
  // Find and disable rules which had no error-free configuration
161
157
  const failingRegistry = registry.getFailingRulesRegistry();
162
158
 
163
- Object.keys(failingRegistry.rules).forEach(function(ruleId) {
159
+ Object.keys(failingRegistry.rules).forEach(ruleId => {
164
160
 
165
161
  // If the rule is recommended, set it to error, otherwise disable it
166
162
  disabledConfigs[ruleId] = (recRules.indexOf(ruleId) !== -1) ? 2 : 0;
@@ -194,9 +190,7 @@ function configureRules(answers, config) {
194
190
  // Log out some stats to let the user know what happened
195
191
  const finalRuleIds = Object.keys(newConfig.rules);
196
192
  const totalRules = finalRuleIds.length;
197
- const enabledRules = finalRuleIds.filter(function(ruleId) {
198
- return (newConfig.rules[ruleId] !== 0);
199
- }).length;
193
+ const enabledRules = finalRuleIds.filter(ruleId => (newConfig.rules[ruleId] !== 0)).length;
200
194
  const resultMessage = [
201
195
  `\nEnabled ${enabledRules} out of ${totalRules}`,
202
196
  `rules based on ${fileQty}`,
@@ -227,7 +221,7 @@ function processAnswers(answers) {
227
221
  if (answers.commonjs) {
228
222
  config.env.commonjs = true;
229
223
  }
230
- answers.env.forEach(function(env) {
224
+ answers.env.forEach(env => {
231
225
  config.env[env] = true;
232
226
  });
233
227
  if (answers.jsx) {
@@ -335,7 +329,7 @@ function promptUser(callback) {
335
329
  return ((answers.source === "guide" && answers.packageJsonExists) || answers.source === "auto");
336
330
  }
337
331
  }
338
- ], function(earlyAnswers) {
332
+ ], earlyAnswers => {
339
333
 
340
334
  // early exit if you are using a style guide
341
335
  if (earlyAnswers.source === "guide") {
@@ -384,9 +378,7 @@ function promptUser(callback) {
384
378
  message: "Do you use CommonJS?",
385
379
  default: false,
386
380
  when(answers) {
387
- return answers.env.some(function(env) {
388
- return env === "browser";
389
- });
381
+ return answers.env.some(env => env === "browser");
390
382
  }
391
383
  },
392
384
  {
@@ -404,7 +396,7 @@ function promptUser(callback) {
404
396
  return answers.jsx;
405
397
  }
406
398
  }
407
- ], function(secondAnswers) {
399
+ ], secondAnswers => {
408
400
 
409
401
  // early exit if you are using automatic style generation
410
402
  if (earlyAnswers.source === "auto") {
@@ -457,7 +449,7 @@ function promptUser(callback) {
457
449
  default: "JavaScript",
458
450
  choices: ["JavaScript", "YAML", "JSON"]
459
451
  }
460
- ], function(answers) {
452
+ ], answers => {
461
453
  try {
462
454
  const totalAnswers = Object.assign({}, earlyAnswers, secondAnswers, answers);
463
455
 
@@ -18,7 +18,7 @@ const debug = require("debug")("eslint:config-ops");
18
18
  //------------------------------------------------------------------------------
19
19
 
20
20
  const RULE_SEVERITY_STRINGS = ["off", "warn", "error"],
21
- RULE_SEVERITY = RULE_SEVERITY_STRINGS.reduce(function(map, value, index) {
21
+ RULE_SEVERITY = RULE_SEVERITY_STRINGS.reduce((map, value, index) => {
22
22
  map[value] = index;
23
23
  return map;
24
24
  }, {}),
@@ -57,9 +57,7 @@ module.exports = {
57
57
 
58
58
  envConfig.env = env;
59
59
 
60
- Object.keys(env).filter(function(name) {
61
- return env[name];
62
- }).forEach(function(name) {
60
+ Object.keys(env).filter(name => env[name]).forEach(name => {
63
61
  const environment = Environments.get(name);
64
62
 
65
63
  if (environment) {
@@ -149,7 +147,7 @@ module.exports = {
149
147
  if (typeof src !== "object" && !Array.isArray(src)) {
150
148
  src = [src];
151
149
  }
152
- Object.keys(src).forEach(function(e, i) {
150
+ Object.keys(src).forEach((e, i) => {
153
151
  e = src[i];
154
152
  if (typeof dst[i] === "undefined") {
155
153
  dst[i] = e;
@@ -171,11 +169,11 @@ module.exports = {
171
169
  });
172
170
  } else {
173
171
  if (target && typeof target === "object") {
174
- Object.keys(target).forEach(function(key) {
172
+ Object.keys(target).forEach(key => {
175
173
  dst[key] = target[key];
176
174
  });
177
175
  }
178
- Object.keys(src).forEach(function(key) {
176
+ Object.keys(src).forEach(key => {
179
177
  if (Array.isArray(src[key]) || Array.isArray(target[key])) {
180
178
  dst[key] = deepmerge(target[key], src[key], key === "plugins", isRule);
181
179
  } else if (typeof src[key] !== "object" || !src[key] || key === "exported" || key === "astGlobals") {
@@ -199,7 +197,7 @@ module.exports = {
199
197
  normalize(config) {
200
198
 
201
199
  if (config.rules) {
202
- Object.keys(config.rules).forEach(function(ruleId) {
200
+ Object.keys(config.rules).forEach(ruleId => {
203
201
  const ruleConfig = config.rules[ruleId];
204
202
 
205
203
  if (typeof ruleConfig === "string") {
@@ -221,7 +219,7 @@ module.exports = {
221
219
  normalizeToStrings(config) {
222
220
 
223
221
  if (config.rules) {
224
- Object.keys(config.rules).forEach(function(ruleId) {
222
+ Object.keys(config.rules).forEach(ruleId => {
225
223
  const ruleConfig = config.rules[ruleId];
226
224
 
227
225
  if (typeof ruleConfig === "number") {