eslint 4.18.0 → 4.19.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 (65) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +2 -2
  3. package/conf/environments.js +3 -1
  4. package/conf/eslint-recommended.js +0 -0
  5. package/lib/ast-utils.js +25 -29
  6. package/lib/cli-engine.js +29 -28
  7. package/lib/code-path-analysis/code-path-state.js +5 -5
  8. package/lib/code-path-analysis/code-path.js +11 -6
  9. package/lib/code-path-analysis/fork-context.js +10 -12
  10. package/lib/config/config-file.js +20 -11
  11. package/lib/config/config-ops.js +8 -10
  12. package/lib/config/config-rule.js +2 -3
  13. package/lib/config/plugins.js +20 -0
  14. package/lib/config.js +7 -8
  15. package/lib/file-finder.js +9 -10
  16. package/lib/ignored-paths.js +4 -4
  17. package/lib/linter.js +397 -406
  18. package/lib/load-rules.js +6 -7
  19. package/lib/rules/accessor-pairs.js +4 -4
  20. package/lib/rules/array-callback-return.js +8 -6
  21. package/lib/rules/array-element-newline.js +4 -4
  22. package/lib/rules/curly.js +11 -10
  23. package/lib/rules/generator-star-spacing.js +1 -2
  24. package/lib/rules/indent-legacy.js +7 -10
  25. package/lib/rules/indent.js +51 -29
  26. package/lib/rules/keyword-spacing.js +6 -18
  27. package/lib/rules/max-len.js +12 -5
  28. package/lib/rules/no-await-in-loop.js +1 -1
  29. package/lib/rules/no-buffer-constructor.js +1 -1
  30. package/lib/rules/no-control-regex.js +51 -72
  31. package/lib/rules/no-else-return.js +7 -6
  32. package/lib/rules/no-empty-character-class.js +1 -1
  33. package/lib/rules/no-eval.js +7 -8
  34. package/lib/rules/no-extra-parens.js +5 -4
  35. package/lib/rules/no-implicit-coercion.js +6 -9
  36. package/lib/rules/no-invalid-regexp.js +53 -36
  37. package/lib/rules/no-irregular-whitespace.js +1 -1
  38. package/lib/rules/no-loop-func.js +9 -11
  39. package/lib/rules/no-magic-numbers.js +17 -10
  40. package/lib/rules/no-return-assign.js +4 -3
  41. package/lib/rules/no-unexpected-multiline.js +1 -1
  42. package/lib/rules/no-unsafe-finally.js +7 -4
  43. package/lib/rules/no-useless-escape.js +2 -2
  44. package/lib/rules/no-useless-return.js +10 -9
  45. package/lib/rules/no-var.js +8 -8
  46. package/lib/rules/object-curly-newline.js +2 -1
  47. package/lib/rules/one-var.js +140 -97
  48. package/lib/rules/padding-line-between-statements.js +6 -4
  49. package/lib/rules/prefer-arrow-callback.js +5 -4
  50. package/lib/rules/prefer-template.js +5 -3
  51. package/lib/rules/space-unary-ops.js +1 -3
  52. package/lib/rules/spaced-comment.js +3 -7
  53. package/lib/rules/template-tag-spacing.js +0 -0
  54. package/lib/rules/valid-jsdoc.js +6 -6
  55. package/lib/rules/vars-on-top.js +7 -17
  56. package/lib/timing.js +3 -5
  57. package/lib/util/glob-util.js +11 -11
  58. package/lib/util/interpolate.js +5 -1
  59. package/lib/util/naming.js +11 -10
  60. package/lib/util/npm-util.js +4 -6
  61. package/lib/util/path-util.js +6 -8
  62. package/lib/util/source-code-util.js +23 -26
  63. package/lib/util/source-code.js +4 -3
  64. package/package.json +4 -3
  65. package/conf/default-config-options.js +0 -29
@@ -79,26 +79,25 @@ class FileFinder {
79
79
  * Does not check if a matching directory entry is a file.
80
80
  * Searches for all the file names in this.fileNames.
81
81
  * Is currently used by lib/config.js to find .eslintrc and package.json files.
82
- * @param {string} directory The directory to start the search from.
82
+ * @param {string} relativeDirectory The directory to start the search from.
83
83
  * @returns {GeneratorFunction} to iterate the file paths found
84
84
  */
85
- *findAllInDirectoryAndParents(directory) {
85
+ *findAllInDirectoryAndParents(relativeDirectory) {
86
86
  const cache = this.cache;
87
87
 
88
- if (directory) {
89
- directory = path.resolve(this.cwd, directory);
90
- } else {
91
- directory = this.cwd;
92
- }
88
+ const initialDirectory = relativeDirectory
89
+ ? path.resolve(this.cwd, relativeDirectory)
90
+ : this.cwd;
93
91
 
94
- if (cache.hasOwnProperty(directory)) {
95
- yield* cache[directory];
92
+ if (cache.hasOwnProperty(initialDirectory)) {
93
+ yield* cache[initialDirectory];
96
94
  return; // to avoid doing the normal loop afterwards
97
95
  }
98
96
 
99
97
  const dirs = [];
100
98
  const fileNames = this.fileNames;
101
99
  let searched = 0;
100
+ let directory = initialDirectory;
102
101
 
103
102
  do {
104
103
  dirs[searched++] = directory;
@@ -135,7 +134,7 @@ class FileFinder {
135
134
 
136
135
  // Add what has been cached previously to the cache of each directory searched.
137
136
  for (let i = 0; i < searched; i++) {
138
- dirs.push.apply(cache[dirs[i]], cache[directory]);
137
+ [].push.apply(cache[dirs[i]], cache[directory]);
139
138
  }
140
139
 
141
140
  yield* cache[dirs[0]];
@@ -76,7 +76,6 @@ function findPackageJSONFile(cwd) {
76
76
  * @returns {Object} Merged options
77
77
  */
78
78
  function mergeDefaultOptions(options) {
79
- options = (options || {});
80
79
  return Object.assign({}, DEFAULT_OPTIONS, options);
81
80
  }
82
81
 
@@ -90,10 +89,11 @@ function mergeDefaultOptions(options) {
90
89
  class IgnoredPaths {
91
90
 
92
91
  /**
93
- * @param {Object} options object containing 'ignore', 'ignorePath' and 'patterns' properties
92
+ * @param {Object} providedOptions object containing 'ignore', 'ignorePath' and 'patterns' properties
94
93
  */
95
- constructor(options) {
96
- options = mergeDefaultOptions(options);
94
+ constructor(providedOptions) {
95
+ const options = mergeDefaultOptions(providedOptions);
96
+
97
97
  this.cache = {};
98
98
 
99
99
  /**