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/util/path-util.js
CHANGED
@@ -48,20 +48,18 @@ function convertPathToPosix(filepath) {
|
|
48
48
|
* @returns {string} Relative filepath
|
49
49
|
*/
|
50
50
|
function getRelativePath(filepath, baseDir) {
|
51
|
-
|
51
|
+
const absolutePath = path.isAbsolute(filepath)
|
52
|
+
? filepath
|
53
|
+
: path.resolve(filepath);
|
52
54
|
|
53
|
-
if (!path.isAbsolute(filepath)) {
|
54
|
-
filepath = path.resolve(filepath);
|
55
|
-
}
|
56
55
|
if (baseDir) {
|
57
56
|
if (!path.isAbsolute(baseDir)) {
|
58
57
|
throw new Error("baseDir should be an absolute path");
|
59
58
|
}
|
60
|
-
|
61
|
-
} else {
|
62
|
-
relativePath = filepath.replace(/^\//, "");
|
59
|
+
return path.relative(baseDir, absolutePath);
|
63
60
|
}
|
64
|
-
return
|
61
|
+
return absolutePath.replace(/^\//, "");
|
62
|
+
|
65
63
|
}
|
66
64
|
|
67
65
|
//------------------------------------------------------------------------------
|
@@ -55,50 +55,47 @@ function getSourceCodeOfFile(filename, options) {
|
|
55
55
|
|
56
56
|
/**
|
57
57
|
* Gets the SourceCode of a single file, or set of files.
|
58
|
-
* @param
|
59
|
-
*
|
60
|
-
* @param
|
61
|
-
*
|
62
|
-
* @param {progressCallback} [cb] Callback for reporting execution status
|
63
|
-
* @returns {Object} The SourceCode of all processed files.
|
58
|
+
* @param {string[]|string} patterns A filename, directory name, or glob, or an array of them
|
59
|
+
* @param {Object} [providedOptions] A CLIEngine options object. If not provided, the default cli options will be used.
|
60
|
+
* @param {progressCallback} [providedCallback] Callback for reporting execution status
|
61
|
+
* @returns {Object} The SourceCode of all processed files.
|
64
62
|
*/
|
65
|
-
function getSourceCodeOfFiles(patterns,
|
63
|
+
function getSourceCodeOfFiles(patterns, providedOptions, providedCallback) {
|
66
64
|
const sourceCodes = {};
|
67
|
-
|
68
|
-
|
69
|
-
if (typeof patterns === "string") {
|
70
|
-
patterns = [patterns];
|
71
|
-
}
|
65
|
+
const globPatternsList = typeof patterns === "string" ? [patterns] : patterns;
|
66
|
+
let options, callback;
|
72
67
|
|
73
68
|
const defaultOptions = Object.assign({}, baseDefaultOptions, { cwd: process.cwd() });
|
74
69
|
|
75
|
-
if (typeof
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
70
|
+
if (typeof providedOptions === "undefined") {
|
71
|
+
options = defaultOptions;
|
72
|
+
callback = null;
|
73
|
+
} else if (typeof providedOptions === "function") {
|
74
|
+
callback = providedOptions;
|
75
|
+
options = defaultOptions;
|
76
|
+
} else if (typeof providedOptions === "object") {
|
77
|
+
options = Object.assign({}, defaultOptions, providedOptions);
|
78
|
+
callback = providedCallback;
|
82
79
|
}
|
83
|
-
debug("constructed options:",
|
84
|
-
|
80
|
+
debug("constructed options:", options);
|
81
|
+
const resolvedPatterns = globUtil.resolveFileGlobPatterns(globPatternsList, options);
|
85
82
|
|
86
|
-
const filenames = globUtil.listFilesToProcess(
|
83
|
+
const filenames = globUtil.listFilesToProcess(resolvedPatterns, options)
|
87
84
|
.filter(fileInfo => !fileInfo.ignored)
|
88
85
|
.reduce((files, fileInfo) => files.concat(fileInfo.filename), []);
|
89
86
|
|
90
87
|
if (filenames.length === 0) {
|
91
|
-
debug(`Did not find any files matching pattern(s): ${
|
88
|
+
debug(`Did not find any files matching pattern(s): ${resolvedPatterns}`);
|
92
89
|
}
|
93
90
|
filenames.forEach(filename => {
|
94
|
-
const sourceCode = getSourceCodeOfFile(filename,
|
91
|
+
const sourceCode = getSourceCodeOfFile(filename, options);
|
95
92
|
|
96
93
|
if (sourceCode) {
|
97
94
|
debug("got sourceCode of", filename);
|
98
95
|
sourceCodes[filename] = sourceCode;
|
99
96
|
}
|
100
|
-
if (
|
101
|
-
|
97
|
+
if (callback) {
|
98
|
+
callback(filenames.length); // eslint-disable-line callback-return
|
102
99
|
}
|
103
100
|
});
|
104
101
|
return sourceCodes;
|
package/lib/util/source-code.js
CHANGED
@@ -90,15 +90,16 @@ class SourceCode extends TokenStore {
|
|
90
90
|
* @param {Object|null} textOrConfig.parserServices - The parser srevices.
|
91
91
|
* @param {ScopeManager|null} textOrConfig.scopeManager - The scope of this source code.
|
92
92
|
* @param {Object|null} textOrConfig.visitorKeys - The visitor keys to traverse AST.
|
93
|
-
* @param {ASTNode} [
|
93
|
+
* @param {ASTNode} [astIfNoConfig] - The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.
|
94
94
|
* @constructor
|
95
95
|
*/
|
96
|
-
constructor(textOrConfig,
|
97
|
-
let text, parserServices, scopeManager, visitorKeys;
|
96
|
+
constructor(textOrConfig, astIfNoConfig) {
|
97
|
+
let text, ast, parserServices, scopeManager, visitorKeys;
|
98
98
|
|
99
99
|
// Process overloading.
|
100
100
|
if (typeof textOrConfig === "string") {
|
101
101
|
text = textOrConfig;
|
102
|
+
ast = astIfNoConfig;
|
102
103
|
} else if (typeof textOrConfig === "object" && textOrConfig !== null) {
|
103
104
|
text = textOrConfig.text;
|
104
105
|
ast = textOrConfig.ast;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.19.1",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -43,7 +43,7 @@
|
|
43
43
|
"doctrine": "^2.1.0",
|
44
44
|
"eslint-scope": "^3.7.1",
|
45
45
|
"eslint-visitor-keys": "^1.0.0",
|
46
|
-
"espree": "^3.5.
|
46
|
+
"espree": "^3.5.4",
|
47
47
|
"esquery": "^1.0.0",
|
48
48
|
"esutils": "^2.0.2",
|
49
49
|
"file-entry-cache": "^2.0.0",
|
@@ -65,11 +65,12 @@
|
|
65
65
|
"path-is-inside": "^1.0.2",
|
66
66
|
"pluralize": "^7.0.0",
|
67
67
|
"progress": "^2.0.0",
|
68
|
+
"regexpp": "^1.0.1",
|
68
69
|
"require-uncached": "^1.0.3",
|
69
70
|
"semver": "^5.3.0",
|
70
71
|
"strip-ansi": "^4.0.0",
|
71
72
|
"strip-json-comments": "~2.0.1",
|
72
|
-
"table": "
|
73
|
+
"table": "4.0.2",
|
73
74
|
"text-table": "~0.2.0"
|
74
75
|
},
|
75
76
|
"devDependencies": {
|
@@ -1,29 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @fileoverview Default config options
|
3
|
-
* @author Teddy Katz
|
4
|
-
*/
|
5
|
-
|
6
|
-
"use strict";
|
7
|
-
|
8
|
-
/**
|
9
|
-
* Freezes an object and all its nested properties
|
10
|
-
* @param {Object} obj The object to deeply freeze
|
11
|
-
* @returns {Object} `obj` after freezing it
|
12
|
-
*/
|
13
|
-
function deepFreeze(obj) {
|
14
|
-
if (obj === null || typeof obj !== "object") {
|
15
|
-
return obj;
|
16
|
-
}
|
17
|
-
|
18
|
-
Object.keys(obj).map(key => obj[key]).forEach(deepFreeze);
|
19
|
-
return Object.freeze(obj);
|
20
|
-
}
|
21
|
-
|
22
|
-
module.exports = deepFreeze({
|
23
|
-
env: {},
|
24
|
-
globals: {},
|
25
|
-
rules: {},
|
26
|
-
settings: {},
|
27
|
-
parser: "espree",
|
28
|
-
parserOptions: {}
|
29
|
-
});
|