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
@@ -307,9 +307,7 @@ RuleTester.prototype = {
307
307
  if (validateSchema.errors) {
308
308
  throw new Error([
309
309
  `Schema for rule ${ruleName} is invalid:`
310
- ].concat(validateSchema.errors.map(function(error) {
311
- return `\t${error.field}: ${error.message}`;
312
- })).join("\n"));
310
+ ].concat(validateSchema.errors.map(error => `\t${error.field}: ${error.message}`)).join("\n"));
313
311
  }
314
312
  }
315
313
 
@@ -321,10 +319,10 @@ RuleTester.prototype = {
321
319
  * running the rule under test.
322
320
  */
323
321
  eslint.reset();
324
- eslint.on("Program", function(node) {
322
+ eslint.on("Program", node => {
325
323
  beforeAST = cloneDeeplyExcludesParent(node);
326
324
 
327
- eslint.on("Program:exit", function(node) {
325
+ eslint.on("Program:exit", node => {
328
326
  afterAST = cloneDeeplyExcludesParent(node);
329
327
  });
330
328
  });
@@ -448,7 +446,7 @@ RuleTester.prototype = {
448
446
  }
449
447
 
450
448
  if (item.errors[i].type) {
451
- assert.equal(messages[i].nodeType, item.errors[i].type, `Error type should be ${item.errors[i].type}`);
449
+ assert.equal(messages[i].nodeType, item.errors[i].type, `Error type should be ${item.errors[i].type}, found ${messages[i].nodeType}`);
452
450
  }
453
451
 
454
452
  if (item.errors[i].hasOwnProperty("line")) {
@@ -488,18 +486,18 @@ RuleTester.prototype = {
488
486
  * This creates a mocha test suite and pipes all supplied info through
489
487
  * one of the templates above.
490
488
  */
491
- RuleTester.describe(ruleName, function() {
492
- RuleTester.describe("valid", function() {
493
- test.valid.forEach(function(valid) {
494
- RuleTester.it(valid.code || valid, function() {
489
+ RuleTester.describe(ruleName, () => {
490
+ RuleTester.describe("valid", () => {
491
+ test.valid.forEach(valid => {
492
+ RuleTester.it(valid.code || valid, () => {
495
493
  testValidTemplate(ruleName, valid);
496
494
  });
497
495
  });
498
496
  });
499
497
 
500
- RuleTester.describe("invalid", function() {
501
- test.invalid.forEach(function(invalid) {
502
- RuleTester.it(invalid.code, function() {
498
+ RuleTester.describe("invalid", () => {
499
+ test.invalid.forEach(invalid => {
500
+ RuleTester.it(invalid.code, () => {
503
501
  testInvalidTemplate(ruleName, invalid);
504
502
  });
505
503
  });
package/lib/timing.js CHANGED
@@ -54,18 +54,16 @@ const ALIGN = [alignLeft, alignRight, alignRight];
54
54
  function display(data) {
55
55
  let total = 0;
56
56
  const rows = Object.keys(data)
57
- .map(function(key) {
57
+ .map(key => {
58
58
  const time = data[key];
59
59
 
60
60
  total += time;
61
61
  return [key, time];
62
62
  })
63
- .sort(function(a, b) {
64
- return b[1] - a[1];
65
- })
63
+ .sort((a, b) => b[1] - a[1])
66
64
  .slice(0, 10);
67
65
 
68
- rows.forEach(function(row) {
66
+ rows.forEach(row => {
69
67
  row.push(`${(row[1] * 100 / total).toFixed(1)}%`);
70
68
  row[1] = row[1].toFixed(3);
71
69
  });
@@ -74,7 +72,7 @@ function display(data) {
74
72
 
75
73
  const widths = [];
76
74
 
77
- rows.forEach(function(row) {
75
+ rows.forEach(row => {
78
76
  const len = row.length;
79
77
 
80
78
  for (let i = 0; i < len; i++) {
@@ -86,13 +84,13 @@ function display(data) {
86
84
  }
87
85
  });
88
86
 
89
- const table = rows.map(function(row) {
90
- return row.map(function(cell, index) {
91
- return ALIGN[index](cell, widths[index]);
92
- }).join(" | ");
93
- });
87
+ const table = rows.map(row =>
88
+ row
89
+ .map((cell, index) => ALIGN[index](cell, widths[index]))
90
+ .join(" | ")
91
+ );
94
92
 
95
- table.splice(1, 0, widths.map(function(w, index) {
93
+ table.splice(1, 0, widths.map((w, index) => {
96
94
  if (index !== 0 && index !== widths.length - 1) {
97
95
  w++;
98
96
  }
@@ -130,7 +128,7 @@ module.exports = (function() {
130
128
  }
131
129
 
132
130
  if (enabled) {
133
- process.on("exit", function() {
131
+ process.on("exit", () => {
134
132
  display(data);
135
133
  });
136
134
  }
@@ -20,7 +20,7 @@
20
20
  */
21
21
  function emitComments(comments, emitter, locs, eventName) {
22
22
  if (comments.length > 0) {
23
- comments.forEach(function(node) {
23
+ comments.forEach(node => {
24
24
  const index = locs.indexOf(node.loc);
25
25
 
26
26
  if (index >= 0) {
@@ -43,9 +43,7 @@ function processPath(options) {
43
43
  const cwd = (options && options.cwd) || process.cwd();
44
44
  let extensions = (options && options.extensions) || [".js"];
45
45
 
46
- extensions = extensions.map(function(ext) {
47
- return ext.charAt(0) === "." ? ext.substr(1) : ext;
48
- });
46
+ extensions = extensions.map(ext => ext.replace(/^\./, ""));
49
47
 
50
48
  let suffix = "/**";
51
49
 
@@ -150,7 +148,7 @@ function listFilesToProcess(globPatterns, options) {
150
148
  }
151
149
 
152
150
  debug("Creating list of files to process.");
153
- globPatterns.forEach(function(pattern) {
151
+ globPatterns.forEach(pattern => {
154
152
  const file = path.resolve(cwd, pattern);
155
153
 
156
154
  if (shell.test("-f", file)) {
@@ -170,7 +168,7 @@ function listFilesToProcess(globPatterns, options) {
170
168
  cwd,
171
169
  };
172
170
 
173
- new GlobSync(pattern, globOptions, shouldIgnore).found.forEach(function(globMatch) {
171
+ new GlobSync(pattern, globOptions, shouldIgnore).found.forEach(globMatch => {
174
172
  addFile(path.resolve(cwd, globMatch), false, ignoredPaths);
175
173
  });
176
174
  }
@@ -89,7 +89,7 @@ function check(packages, opt) {
89
89
  if (opt.dependencies && typeof fileJson.dependencies === "object") {
90
90
  deps = deps.concat(Object.keys(fileJson.dependencies));
91
91
  }
92
- return packages.reduce(function(status, pkg) {
92
+ return packages.reduce((status, pkg) => {
93
93
  status[pkg] = deps.indexOf(pkg) !== -1;
94
94
  return status;
95
95
  }, {});
@@ -72,7 +72,7 @@ SourceCodeFixer.applyFixes = function(sourceCode, messages) {
72
72
  let lastFixPos = text.length + 1,
73
73
  prefix = (sourceCode.hasBOM ? BOM : "");
74
74
 
75
- messages.forEach(function(problem) {
75
+ messages.forEach(problem => {
76
76
  if (problem.hasOwnProperty("fix")) {
77
77
  fixes.push(problem);
78
78
  } else {
@@ -84,14 +84,12 @@ SourceCodeFixer.applyFixes = function(sourceCode, messages) {
84
84
  debug("Found fixes to apply");
85
85
 
86
86
  // sort in reverse order of occurrence
87
- fixes.sort(function(a, b) {
88
- return b.fix.range[1] - a.fix.range[1] || b.fix.range[0] - a.fix.range[0];
89
- });
87
+ fixes.sort((a, b) => b.fix.range[1] - a.fix.range[1] || b.fix.range[0] - a.fix.range[0]);
90
88
 
91
89
  // split into array of characters for easier manipulation
92
90
  const chars = text.split("");
93
91
 
94
- fixes.forEach(function(problem) {
92
+ fixes.forEach(problem => {
95
93
  const fix = problem.fix;
96
94
  let start = fix.range[0];
97
95
  const end = fix.range[1];
@@ -84,14 +84,14 @@ function getSourceCodeOfFiles(patterns, options, cb) {
84
84
  debug("constructed options:", opts);
85
85
  patterns = globUtil.resolveFileGlobPatterns(patterns, opts);
86
86
 
87
- const filenames = globUtil.listFilesToProcess(patterns, opts).reduce(function(files, fileInfo) {
88
- return !fileInfo.ignored ? files.concat(fileInfo.filename) : files;
89
- }, []);
87
+ const filenames = globUtil.listFilesToProcess(patterns, opts)
88
+ .filter(fileInfo => !fileInfo.ignored)
89
+ .reduce((files, fileInfo) => files.concat(fileInfo.filename), []);
90
90
 
91
91
  if (filenames.length === 0) {
92
92
  debug(`Did not find any files matching pattern(s): ${patterns}`);
93
93
  }
94
- filenames.forEach(function(filename) {
94
+ filenames.forEach(filename => {
95
95
  const sourceCode = getSourceCodeOfFile(filename, opts);
96
96
 
97
97
  if (sourceCode) {
@@ -117,9 +117,9 @@ function SourceCode(text, ast) {
117
117
  */
118
118
  this.lines = SourceCode.splitLines(this.text);
119
119
 
120
- this.tokensAndComments = ast.tokens.concat(ast.comments).sort(function(left, right) {
121
- return left.range[0] - right.range[0];
122
- });
120
+ this.tokensAndComments = ast.tokens
121
+ .concat(ast.comments)
122
+ .sort((left, right) => left.range[0] - right.range[0]);
123
123
 
124
124
  // create token store methods
125
125
  const tokenStore = createTokenStore(ast.tokens);
@@ -46,9 +46,7 @@ function Traverser() {
46
46
  * @private
47
47
  */
48
48
  Traverser.getKeys = function(node) {
49
- return Object.keys(node).filter(function(key) {
50
- return KEY_BLACKLIST.indexOf(key) === -1;
51
- });
49
+ return Object.keys(node).filter(key => KEY_BLACKLIST.indexOf(key) === -1);
52
50
  };
53
51
 
54
52
  module.exports = Traverser;
@@ -15,7 +15,7 @@
15
15
  * @private
16
16
  */
17
17
  module.exports = function(s) {
18
- return (`${s}`).replace(/[<>&"'\x00-\x1F\x7F\u0080-\uFFFF]/g, function(c) { // eslint-disable-line no-control-regex
18
+ return (`${s}`).replace(/[<>&"'\x00-\x1F\x7F\u0080-\uFFFF]/g, c => { // eslint-disable-line no-control-regex
19
19
  switch (c) {
20
20
  case "<":
21
21
  return "&lt;";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint",
3
- "version": "3.9.0",
3
+ "version": "3.10.2",
4
4
  "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
5
5
  "description": "An AST-based pattern checker for JavaScript.",
6
6
  "bin": {
@@ -46,7 +46,7 @@
46
46
  "file-entry-cache": "^2.0.0",
47
47
  "glob": "^7.0.3",
48
48
  "globals": "^9.2.0",
49
- "ignore": "^3.1.5",
49
+ "ignore": "^3.2.0",
50
50
  "imurmurhash": "^0.1.4",
51
51
  "inquirer": "^0.12.0",
52
52
  "is-my-json-valid": "^2.10.0",
@@ -98,7 +98,7 @@
98
98
  "load-perf": "^0.2.0",
99
99
  "markdownlint": "^0.2.0",
100
100
  "mocha": "^2.4.5",
101
- "mock-fs": "3.11.0",
101
+ "mock-fs": "^3.12.1",
102
102
  "npm-license": "^0.3.2",
103
103
  "phantomjs-prebuilt": "^2.1.7",
104
104
  "proxyquire": "^1.7.10",