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.
- package/CHANGELOG.md +40 -0
- package/README.md +2 -2
- package/conf/environments.js +3 -1
- package/conf/eslint-recommended.js +0 -0
- package/lib/ast-utils.js +25 -29
- package/lib/cli-engine.js +29 -28
- package/lib/code-path-analysis/code-path-state.js +5 -5
- package/lib/code-path-analysis/code-path.js +11 -6
- package/lib/code-path-analysis/fork-context.js +10 -12
- package/lib/config/config-file.js +20 -11
- package/lib/config/config-ops.js +8 -10
- package/lib/config/config-rule.js +2 -3
- package/lib/config/plugins.js +20 -0
- package/lib/config.js +7 -8
- package/lib/file-finder.js +9 -10
- package/lib/ignored-paths.js +4 -4
- package/lib/linter.js +397 -406
- package/lib/load-rules.js +6 -7
- package/lib/rules/accessor-pairs.js +4 -4
- package/lib/rules/array-callback-return.js +8 -6
- package/lib/rules/array-element-newline.js +4 -4
- package/lib/rules/curly.js +11 -10
- package/lib/rules/generator-star-spacing.js +1 -2
- package/lib/rules/indent-legacy.js +7 -10
- package/lib/rules/indent.js +51 -29
- package/lib/rules/keyword-spacing.js +6 -18
- package/lib/rules/max-len.js +12 -5
- package/lib/rules/no-await-in-loop.js +1 -1
- package/lib/rules/no-buffer-constructor.js +1 -1
- package/lib/rules/no-control-regex.js +51 -72
- package/lib/rules/no-else-return.js +7 -6
- package/lib/rules/no-empty-character-class.js +1 -1
- package/lib/rules/no-eval.js +7 -8
- package/lib/rules/no-extra-parens.js +5 -4
- package/lib/rules/no-implicit-coercion.js +6 -9
- package/lib/rules/no-invalid-regexp.js +53 -36
- package/lib/rules/no-irregular-whitespace.js +1 -1
- package/lib/rules/no-loop-func.js +9 -11
- package/lib/rules/no-magic-numbers.js +17 -10
- package/lib/rules/no-return-assign.js +4 -3
- package/lib/rules/no-unexpected-multiline.js +1 -1
- package/lib/rules/no-unsafe-finally.js +7 -4
- package/lib/rules/no-useless-escape.js +2 -2
- package/lib/rules/no-useless-return.js +10 -9
- package/lib/rules/no-var.js +8 -8
- package/lib/rules/object-curly-newline.js +2 -1
- package/lib/rules/one-var.js +140 -97
- package/lib/rules/padding-line-between-statements.js +6 -4
- package/lib/rules/prefer-arrow-callback.js +5 -4
- package/lib/rules/prefer-template.js +5 -3
- package/lib/rules/space-unary-ops.js +1 -3
- package/lib/rules/spaced-comment.js +3 -7
- package/lib/rules/template-tag-spacing.js +0 -0
- package/lib/rules/valid-jsdoc.js +6 -6
- package/lib/rules/vars-on-top.js +7 -17
- package/lib/timing.js +3 -5
- package/lib/util/glob-util.js +11 -11
- package/lib/util/interpolate.js +5 -1
- package/lib/util/naming.js +11 -10
- package/lib/util/npm-util.js +4 -6
- package/lib/util/path-util.js +6 -8
- package/lib/util/source-code-util.js +23 -26
- package/lib/util/source-code.js +4 -3
- package/package.json +4 -3
- package/conf/default-config-options.js +0 -29
package/lib/file-finder.js
CHANGED
@@ -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}
|
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(
|
85
|
+
*findAllInDirectoryAndParents(relativeDirectory) {
|
86
86
|
const cache = this.cache;
|
87
87
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
directory = this.cwd;
|
92
|
-
}
|
88
|
+
const initialDirectory = relativeDirectory
|
89
|
+
? path.resolve(this.cwd, relativeDirectory)
|
90
|
+
: this.cwd;
|
93
91
|
|
94
|
-
if (cache.hasOwnProperty(
|
95
|
-
yield* cache[
|
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
|
-
|
137
|
+
[].push.apply(cache[dirs[i]], cache[directory]);
|
139
138
|
}
|
140
139
|
|
141
140
|
yield* cache[dirs[0]];
|
package/lib/ignored-paths.js
CHANGED
@@ -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}
|
92
|
+
* @param {Object} providedOptions object containing 'ignore', 'ignorePath' and 'patterns' properties
|
94
93
|
*/
|
95
|
-
constructor(
|
96
|
-
options = mergeDefaultOptions(
|
94
|
+
constructor(providedOptions) {
|
95
|
+
const options = mergeDefaultOptions(providedOptions);
|
96
|
+
|
97
97
|
this.cache = {};
|
98
98
|
|
99
99
|
/**
|