eslint 5.0.1 → 5.4.0
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 +84 -0
- package/README.md +1 -1
- package/conf/eslint-recommended.js +4 -0
- package/lib/cli-engine.js +38 -78
- package/lib/cli.js +1 -1
- package/lib/code-path-analysis/code-path-analyzer.js +2 -2
- package/lib/config/config-initializer.js +8 -8
- package/lib/config/config-validator.js +13 -6
- package/lib/config.js +1 -1
- package/lib/formatters/stylish.js +1 -1
- package/lib/ignored-paths.js +125 -37
- package/lib/linter.js +6 -7
- package/lib/rules/array-bracket-newline.js +1 -1
- package/lib/rules/array-bracket-spacing.js +1 -1
- package/lib/rules/array-callback-return.js +1 -1
- package/lib/rules/array-element-newline.js +1 -1
- package/lib/rules/arrow-body-style.js +1 -1
- package/lib/rules/arrow-parens.js +1 -1
- package/lib/rules/arrow-spacing.js +1 -1
- package/lib/rules/block-spacing.js +1 -1
- package/lib/rules/brace-style.js +1 -1
- package/lib/rules/capitalized-comments.js +1 -1
- package/lib/rules/comma-dangle.js +1 -1
- package/lib/rules/comma-spacing.js +1 -1
- package/lib/rules/comma-style.js +2 -2
- package/lib/rules/complexity.js +3 -3
- package/lib/rules/computed-property-spacing.js +1 -1
- package/lib/rules/consistent-return.js +1 -1
- package/lib/rules/curly.js +1 -1
- package/lib/rules/dot-location.js +1 -1
- package/lib/rules/dot-notation.js +1 -1
- package/lib/rules/eqeqeq.js +1 -1
- package/lib/rules/func-call-spacing.js +1 -1
- package/lib/rules/func-name-matching.js +1 -1
- package/lib/rules/func-names.js +1 -1
- package/lib/rules/function-paren-newline.js +1 -1
- package/lib/rules/getter-return.js +1 -1
- package/lib/rules/indent-legacy.js +1 -1
- package/lib/rules/indent.js +43 -7
- package/lib/rules/jsx-quotes.js +1 -1
- package/lib/rules/key-spacing.js +2 -2
- package/lib/rules/keyword-spacing.js +1 -1
- package/lib/rules/line-comment-position.js +3 -3
- package/lib/rules/linebreak-style.js +1 -1
- package/lib/rules/lines-around-comment.js +1 -1
- package/lib/rules/lines-around-directive.js +1 -1
- package/lib/rules/lines-between-class-members.js +1 -1
- package/lib/rules/max-depth.js +2 -2
- package/lib/rules/max-len.js +1 -1
- package/lib/rules/max-lines-per-function.js +1 -1
- package/lib/rules/max-lines.js +2 -2
- package/lib/rules/max-nested-callbacks.js +2 -2
- package/lib/rules/max-params.js +3 -3
- package/lib/rules/max-statements-per-line.js +1 -1
- package/lib/rules/max-statements.js +3 -3
- package/lib/rules/multiline-comment-style.js +1 -1
- package/lib/rules/multiline-ternary.js +1 -1
- package/lib/rules/new-parens.js +1 -1
- package/lib/rules/newline-after-var.js +1 -1
- package/lib/rules/newline-per-chained-call.js +1 -1
- package/lib/rules/no-alert.js +1 -1
- package/lib/rules/no-async-promise-executor.js +33 -0
- package/lib/rules/no-catch-shadow.js +5 -2
- package/lib/rules/no-class-assign.js +1 -1
- package/lib/rules/no-cond-assign.js +1 -1
- package/lib/rules/no-confusing-arrow.js +1 -1
- package/lib/rules/no-console.js +1 -1
- package/lib/rules/no-const-assign.js +1 -1
- package/lib/rules/no-debugger.js +2 -10
- package/lib/rules/no-dupe-keys.js +1 -1
- package/lib/rules/no-else-return.js +1 -1
- package/lib/rules/no-empty-function.js +1 -1
- package/lib/rules/no-empty.js +1 -1
- package/lib/rules/no-eval.js +1 -1
- package/lib/rules/no-ex-assign.js +1 -1
- package/lib/rules/no-extend-native.js +1 -1
- package/lib/rules/no-extra-bind.js +1 -1
- package/lib/rules/no-extra-boolean-cast.js +1 -1
- package/lib/rules/no-extra-label.js +1 -1
- package/lib/rules/no-extra-parens.js +2 -2
- package/lib/rules/no-extra-semi.js +1 -1
- package/lib/rules/no-floating-decimal.js +1 -1
- package/lib/rules/no-func-assign.js +1 -1
- package/lib/rules/no-implicit-coercion.js +1 -1
- package/lib/rules/no-inline-comments.js +1 -1
- package/lib/rules/no-invalid-this.js +1 -1
- package/lib/rules/no-irregular-whitespace.js +1 -1
- package/lib/rules/no-label-var.js +1 -1
- package/lib/rules/no-labels.js +1 -1
- package/lib/rules/no-misleading-character-class.js +189 -0
- package/lib/rules/no-mixed-operators.js +1 -1
- package/lib/rules/no-multi-spaces.js +1 -1
- package/lib/rules/no-multi-str.js +1 -1
- package/lib/rules/no-regex-spaces.js +1 -1
- package/lib/rules/no-restricted-globals.js +1 -1
- package/lib/rules/no-restricted-imports.js +1 -1
- package/lib/rules/no-restricted-modules.js +1 -1
- package/lib/rules/no-restricted-properties.js +1 -1
- package/lib/rules/no-return-assign.js +1 -1
- package/lib/rules/no-return-await.js +1 -1
- package/lib/rules/no-self-assign.js +1 -1
- package/lib/rules/no-sequences.js +1 -1
- package/lib/rules/no-shadow.js +1 -1
- package/lib/rules/no-this-before-super.js +1 -1
- package/lib/rules/no-throw-literal.js +1 -1
- package/lib/rules/no-trailing-spaces.js +1 -1
- package/lib/rules/no-undef-init.js +1 -1
- package/lib/rules/no-unexpected-multiline.js +1 -1
- package/lib/rules/no-unmodified-loop-condition.js +2 -3
- package/lib/rules/no-unneeded-ternary.js +1 -1
- package/lib/rules/no-unsafe-negation.js +1 -1
- package/lib/rules/no-unused-vars.js +1 -1
- package/lib/rules/no-useless-call.js +1 -1
- package/lib/rules/no-useless-computed-key.js +1 -1
- package/lib/rules/no-useless-concat.js +1 -1
- package/lib/rules/no-useless-escape.js +1 -1
- package/lib/rules/no-useless-return.js +2 -11
- package/lib/rules/no-var.js +1 -1
- package/lib/rules/no-warning-comments.js +1 -1
- package/lib/rules/no-whitespace-before-property.js +1 -1
- package/lib/rules/object-curly-newline.js +1 -1
- package/lib/rules/object-curly-spacing.js +1 -1
- package/lib/rules/object-shorthand.js +1 -1
- package/lib/rules/one-var.js +6 -6
- package/lib/rules/operator-assignment.js +1 -1
- package/lib/rules/operator-linebreak.js +1 -1
- package/lib/rules/padded-blocks.js +6 -6
- package/lib/rules/padding-line-between-statements.js +2 -2
- package/lib/rules/prefer-const.js +3 -12
- package/lib/rules/prefer-object-spread.js +154 -197
- package/lib/rules/prefer-promise-reject-errors.js +1 -1
- package/lib/rules/prefer-reflect.js +1 -1
- package/lib/rules/prefer-spread.js +1 -1
- package/lib/rules/prefer-template.js +1 -1
- package/lib/rules/quotes.js +1 -1
- package/lib/rules/radix.js +1 -1
- package/lib/rules/require-atomic-updates.js +239 -0
- package/lib/rules/require-await.js +1 -1
- package/lib/rules/require-unicode-regexp.js +65 -0
- package/lib/rules/semi-spacing.js +3 -3
- package/lib/rules/semi-style.js +1 -1
- package/lib/rules/semi.js +1 -1
- package/lib/rules/sort-keys.js +2 -2
- package/lib/rules/space-before-blocks.js +1 -1
- package/lib/rules/space-before-function-paren.js +1 -1
- package/lib/rules/space-in-parens.js +1 -1
- package/lib/rules/space-unary-ops.js +2 -2
- package/lib/rules/spaced-comment.js +1 -1
- package/lib/rules/strict.js +1 -1
- package/lib/rules/switch-colon-spacing.js +1 -1
- package/lib/rules/symbol-description.js +1 -1
- package/lib/rules/template-curly-spacing.js +1 -1
- package/lib/rules/valid-jsdoc.js +1 -1
- package/lib/rules/wrap-iife.js +1 -1
- package/lib/rules/wrap-regex.js +8 -4
- package/lib/rules/yoda.js +1 -1
- package/lib/testers/rule-tester.js +8 -10
- package/lib/token-store/index.js +1 -1
- package/lib/{ast-utils.js → util/ast-utils.js} +0 -0
- package/lib/{file-finder.js → util/file-finder.js} +2 -2
- package/lib/util/fix-tracker.js +1 -1
- package/lib/util/{glob-util.js → glob-utils.js} +4 -4
- package/lib/util/lint-result-cache.js +146 -0
- package/lib/{logging.js → util/logging.js} +0 -0
- package/lib/util/naming.js +2 -2
- package/lib/util/node-event-generator.js +3 -3
- package/lib/util/{npm-util.js → npm-utils.js} +1 -1
- package/lib/util/{path-util.js → path-utils.js} +1 -1
- package/lib/util/source-code-fixer.js +1 -1
- package/lib/util/{source-code-util.js → source-code-utils.js} +3 -3
- package/lib/util/source-code.js +1 -1
- package/lib/{timing.js → util/timing.js} +0 -0
- package/lib/util/unicode/index.js +11 -0
- package/lib/util/unicode/is-combining-character.js +13 -0
- package/lib/util/unicode/is-emoji-modifier.js +13 -0
- package/lib/util/unicode/is-regional-indicator-symbol.js +13 -0
- package/lib/util/unicode/is-surrogate-pair.js +14 -0
- package/package.json +6 -6
- package/lib/rules/.eslintrc.yml +0 -4
package/lib/ignored-paths.js
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
const fs = require("fs"),
|
13
13
|
path = require("path"),
|
14
14
|
ignore = require("ignore"),
|
15
|
-
|
15
|
+
pathUtils = require("./util/path-utils");
|
16
16
|
|
17
17
|
const debug = require("debug")("eslint:ignored-paths");
|
18
18
|
|
@@ -79,6 +79,40 @@ function mergeDefaultOptions(options) {
|
|
79
79
|
return Object.assign({}, DEFAULT_OPTIONS, options);
|
80
80
|
}
|
81
81
|
|
82
|
+
/* eslint-disable valid-jsdoc */
|
83
|
+
/**
|
84
|
+
* Normalize the path separators in a given string.
|
85
|
+
* On Windows environment, this replaces `\` by `/`.
|
86
|
+
* Otherwrise, this does nothing.
|
87
|
+
* @param {string} str The path string to normalize.
|
88
|
+
* @returns {string} The normalized path.
|
89
|
+
*/
|
90
|
+
const normalizePathSeps = path.sep === "/"
|
91
|
+
? (str => str)
|
92
|
+
: ((seps, str) => str.replace(seps, "/")).bind(null, new RegExp(`\\${path.sep}`, "g"));
|
93
|
+
/* eslint-enable valid-jsdoc */
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Converts a glob pattern to a new glob pattern relative to a different directory
|
97
|
+
* @param {string} globPattern The glob pattern, relative the the old base directory
|
98
|
+
* @param {string} relativePathToOldBaseDir A relative path from the new base directory to the old one
|
99
|
+
* @returns {string} A glob pattern relative to the new base directory
|
100
|
+
*/
|
101
|
+
function relativize(globPattern, relativePathToOldBaseDir) {
|
102
|
+
if (relativePathToOldBaseDir === "") {
|
103
|
+
return globPattern;
|
104
|
+
}
|
105
|
+
|
106
|
+
const prefix = globPattern.startsWith("!") ? "!" : "";
|
107
|
+
const globWithoutPrefix = globPattern.replace(/^!/, "");
|
108
|
+
|
109
|
+
if (globWithoutPrefix.startsWith("/")) {
|
110
|
+
return `${prefix}/${normalizePathSeps(relativePathToOldBaseDir)}${globWithoutPrefix}`;
|
111
|
+
}
|
112
|
+
|
113
|
+
return globPattern;
|
114
|
+
}
|
115
|
+
|
82
116
|
//------------------------------------------------------------------------------
|
83
117
|
// Public Interface
|
84
118
|
//------------------------------------------------------------------------------
|
@@ -96,41 +130,36 @@ class IgnoredPaths {
|
|
96
130
|
|
97
131
|
this.cache = {};
|
98
132
|
|
99
|
-
/**
|
100
|
-
* add pattern to node-ignore instance
|
101
|
-
* @param {Object} ig, instance of node-ignore
|
102
|
-
* @param {string} pattern, pattern do add to ig
|
103
|
-
* @returns {array} raw ignore rules
|
104
|
-
*/
|
105
|
-
function addPattern(ig, pattern) {
|
106
|
-
return ig.addPattern(pattern);
|
107
|
-
}
|
108
|
-
|
109
133
|
this.defaultPatterns = [].concat(DEFAULT_IGNORE_DIRS, options.patterns || []);
|
110
|
-
|
134
|
+
|
135
|
+
this.ignoreFileDir = options.ignore !== false && options.ignorePath
|
136
|
+
? path.dirname(path.resolve(options.cwd, options.ignorePath))
|
137
|
+
: options.cwd;
|
138
|
+
this.options = options;
|
139
|
+
this._baseDir = null;
|
111
140
|
|
112
141
|
this.ig = {
|
113
142
|
custom: ignore(),
|
114
143
|
default: ignore()
|
115
144
|
};
|
116
145
|
|
117
|
-
|
118
|
-
* Add a way to keep track of ignored files. This was present in node-ignore
|
119
|
-
* 2.x, but dropped for now as of 3.0.10.
|
120
|
-
*/
|
121
|
-
this.ig.custom.ignoreFiles = [];
|
122
|
-
this.ig.default.ignoreFiles = [];
|
123
|
-
|
146
|
+
this.defaultPatterns.forEach(pattern => this.addPatternRelativeToCwd(this.ig.default, pattern));
|
124
147
|
if (options.dotfiles !== true) {
|
125
148
|
|
126
149
|
/*
|
127
150
|
* ignore files beginning with a dot, but not files in a parent or
|
128
151
|
* ancestor directory (which in relative format will begin with `../`).
|
129
152
|
*/
|
130
|
-
|
153
|
+
this.addPatternRelativeToCwd(this.ig.default, ".*");
|
154
|
+
this.addPatternRelativeToCwd(this.ig.default, "!../");
|
131
155
|
}
|
132
156
|
|
133
|
-
|
157
|
+
/*
|
158
|
+
* Add a way to keep track of ignored files. This was present in node-ignore
|
159
|
+
* 2.x, but dropped for now as of 3.0.10.
|
160
|
+
*/
|
161
|
+
this.ig.custom.ignoreFiles = [];
|
162
|
+
this.ig.default.ignoreFiles = [];
|
134
163
|
|
135
164
|
if (options.ignore !== false) {
|
136
165
|
let ignorePath;
|
@@ -154,13 +183,11 @@ class IgnoredPaths {
|
|
154
183
|
debug(`Loaded ignore file ${ignorePath}`);
|
155
184
|
} catch (e) {
|
156
185
|
debug("Could not find ignore file in cwd");
|
157
|
-
this.options = options;
|
158
186
|
}
|
159
187
|
}
|
160
188
|
|
161
189
|
if (ignorePath) {
|
162
190
|
debug(`Adding ${ignorePath}`);
|
163
|
-
this.baseDir = path.dirname(path.resolve(options.cwd, ignorePath));
|
164
191
|
this.addIgnoreFile(this.ig.custom, ignorePath);
|
165
192
|
this.addIgnoreFile(this.ig.default, ignorePath);
|
166
193
|
} else {
|
@@ -187,8 +214,8 @@ class IgnoredPaths {
|
|
187
214
|
if (packageJSONOptions.eslintIgnore) {
|
188
215
|
if (Array.isArray(packageJSONOptions.eslintIgnore)) {
|
189
216
|
packageJSONOptions.eslintIgnore.forEach(pattern => {
|
190
|
-
|
191
|
-
|
217
|
+
this.addPatternRelativeToIgnoreFile(this.ig.custom, pattern);
|
218
|
+
this.addPatternRelativeToIgnoreFile(this.ig.default, pattern);
|
192
219
|
});
|
193
220
|
} else {
|
194
221
|
throw new TypeError("Package.json eslintIgnore property requires an array of paths");
|
@@ -202,12 +229,68 @@ class IgnoredPaths {
|
|
202
229
|
}
|
203
230
|
|
204
231
|
if (options.ignorePattern) {
|
205
|
-
|
206
|
-
|
232
|
+
this.addPatternRelativeToCwd(this.ig.custom, options.ignorePattern);
|
233
|
+
this.addPatternRelativeToCwd(this.ig.default, options.ignorePattern);
|
207
234
|
}
|
208
235
|
}
|
236
|
+
}
|
209
237
|
|
210
|
-
|
238
|
+
/*
|
239
|
+
* If `ignoreFileDir` is a subdirectory of `cwd`, all paths will be normalized to be relative to `cwd`.
|
240
|
+
* Otherwise, all paths will be normalized to be relative to `ignoreFileDir`.
|
241
|
+
* This ensures that the final normalized ignore rule will not contain `..`, which is forbidden in
|
242
|
+
* ignore rules.
|
243
|
+
*/
|
244
|
+
|
245
|
+
addPatternRelativeToCwd(ig, pattern) {
|
246
|
+
const baseDir = this.getBaseDir();
|
247
|
+
const cookedPattern = baseDir === this.options.cwd
|
248
|
+
? pattern
|
249
|
+
: relativize(pattern, path.relative(baseDir, this.options.cwd));
|
250
|
+
|
251
|
+
ig.addPattern(cookedPattern);
|
252
|
+
debug("addPatternRelativeToCwd:\n original = %j\n cooked = %j", pattern, cookedPattern);
|
253
|
+
}
|
254
|
+
|
255
|
+
addPatternRelativeToIgnoreFile(ig, pattern) {
|
256
|
+
const baseDir = this.getBaseDir();
|
257
|
+
const cookedPattern = baseDir === this.ignoreFileDir
|
258
|
+
? pattern
|
259
|
+
: relativize(pattern, path.relative(baseDir, this.ignoreFileDir));
|
260
|
+
|
261
|
+
ig.addPattern(cookedPattern);
|
262
|
+
debug("addPatternRelativeToIgnoreFile:\n original = %j\n cooked = %j", pattern, cookedPattern);
|
263
|
+
}
|
264
|
+
|
265
|
+
// Detect the common ancestor
|
266
|
+
getBaseDir() {
|
267
|
+
if (!this._baseDir) {
|
268
|
+
const a = path.resolve(this.options.cwd);
|
269
|
+
const b = path.resolve(this.ignoreFileDir);
|
270
|
+
let lastSepPos = 0;
|
271
|
+
|
272
|
+
// Set the shorter one (it's the common ancestor if one includes the other).
|
273
|
+
this._baseDir = a.length < b.length ? a : b;
|
274
|
+
|
275
|
+
// Set the common ancestor.
|
276
|
+
for (let i = 0; i < a.length && i < b.length; ++i) {
|
277
|
+
if (a[i] !== b[i]) {
|
278
|
+
this._baseDir = a.slice(0, lastSepPos);
|
279
|
+
break;
|
280
|
+
}
|
281
|
+
if (a[i] === path.sep) {
|
282
|
+
lastSepPos = i;
|
283
|
+
}
|
284
|
+
}
|
285
|
+
|
286
|
+
// If it's only Windows drive letter, it needs \
|
287
|
+
if (/^[A-Z]:$/.test(this._baseDir)) {
|
288
|
+
this._baseDir += "\\";
|
289
|
+
}
|
290
|
+
|
291
|
+
debug("baseDir = %j", this._baseDir);
|
292
|
+
}
|
293
|
+
return this._baseDir;
|
211
294
|
}
|
212
295
|
|
213
296
|
/**
|
@@ -217,7 +300,7 @@ class IgnoredPaths {
|
|
217
300
|
*/
|
218
301
|
readIgnoreFile(filePath) {
|
219
302
|
if (typeof this.cache[filePath] === "undefined") {
|
220
|
-
this.cache[filePath] = fs.readFileSync(filePath, "utf8");
|
303
|
+
this.cache[filePath] = fs.readFileSync(filePath, "utf8").split(/\r?\n/g).filter(Boolean);
|
221
304
|
}
|
222
305
|
return this.cache[filePath];
|
223
306
|
}
|
@@ -226,11 +309,13 @@ class IgnoredPaths {
|
|
226
309
|
* add ignore file to node-ignore instance
|
227
310
|
* @param {Object} ig, instance of node-ignore
|
228
311
|
* @param {string} filePath, file to add to ig
|
229
|
-
* @returns {
|
312
|
+
* @returns {void}
|
230
313
|
*/
|
231
314
|
addIgnoreFile(ig, filePath) {
|
232
315
|
ig.ignoreFiles.push(filePath);
|
233
|
-
|
316
|
+
this
|
317
|
+
.readIgnoreFile(filePath)
|
318
|
+
.forEach(ignoreRule => this.addPatternRelativeToIgnoreFile(ig, ignoreRule));
|
234
319
|
}
|
235
320
|
|
236
321
|
/**
|
@@ -243,7 +328,7 @@ class IgnoredPaths {
|
|
243
328
|
|
244
329
|
let result = false;
|
245
330
|
const absolutePath = path.resolve(this.options.cwd, filepath);
|
246
|
-
const relativePath =
|
331
|
+
const relativePath = pathUtils.getRelativePath(absolutePath, this.getBaseDir());
|
247
332
|
|
248
333
|
if (typeof category === "undefined") {
|
249
334
|
result = (this.ig.default.filter([relativePath]).length === 0) ||
|
@@ -251,6 +336,9 @@ class IgnoredPaths {
|
|
251
336
|
} else {
|
252
337
|
result = (this.ig[category].filter([relativePath]).length === 0);
|
253
338
|
}
|
339
|
+
debug("contains:");
|
340
|
+
debug(" target = %j", filepath);
|
341
|
+
debug(" result = %j", result);
|
254
342
|
|
255
343
|
return result;
|
256
344
|
|
@@ -261,13 +349,15 @@ class IgnoredPaths {
|
|
261
349
|
* @returns {function()} method to check whether a folder should be ignored by glob.
|
262
350
|
*/
|
263
351
|
getIgnoredFoldersGlobChecker() {
|
352
|
+
const baseDir = this.getBaseDir();
|
353
|
+
const ig = ignore();
|
264
354
|
|
265
|
-
|
355
|
+
DEFAULT_IGNORE_DIRS.forEach(ignoreDir => this.addPatternRelativeToCwd(ig, ignoreDir));
|
266
356
|
|
267
357
|
if (this.options.dotfiles !== true) {
|
268
358
|
|
269
359
|
// Ignore hidden folders. (This cannot be ".*", or else it's not possible to unignore hidden files)
|
270
|
-
ig.add([".*/*", "
|
360
|
+
ig.add([".*/*", "!../*"]);
|
271
361
|
}
|
272
362
|
|
273
363
|
if (this.options.ignore) {
|
@@ -276,10 +366,8 @@ class IgnoredPaths {
|
|
276
366
|
|
277
367
|
const filter = ig.createFilter();
|
278
368
|
|
279
|
-
const base = this.baseDir;
|
280
|
-
|
281
369
|
return function(absolutePath) {
|
282
|
-
const relative =
|
370
|
+
const relative = pathUtils.getRelativePath(absolutePath, baseDir);
|
283
371
|
|
284
372
|
if (!relative) {
|
285
373
|
return false;
|
package/lib/linter.js
CHANGED
@@ -24,8 +24,8 @@ const eslintScope = require("eslint-scope"),
|
|
24
24
|
Traverser = require("./util/traverser"),
|
25
25
|
createReportTranslator = require("./report-translator"),
|
26
26
|
Rules = require("./rules"),
|
27
|
-
timing = require("./timing"),
|
28
|
-
astUtils = require("./ast-utils"),
|
27
|
+
timing = require("./util/timing"),
|
28
|
+
astUtils = require("./util/ast-utils"),
|
29
29
|
pkg = require("../package.json"),
|
30
30
|
SourceCodeFixer = require("./util/source-code-fixer");
|
31
31
|
|
@@ -465,11 +465,10 @@ function resolveParserOptions(parserName, providedOptions, enabledEnvironments)
|
|
465
465
|
* @returns {Object} The resolved globals object
|
466
466
|
*/
|
467
467
|
function resolveGlobals(providedGlobals, enabledEnvironments) {
|
468
|
-
return Object.assign
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
.concat(providedGlobals)
|
468
|
+
return Object.assign(
|
469
|
+
{},
|
470
|
+
...enabledEnvironments.filter(env => env.globals).map(env => env.globals),
|
471
|
+
providedGlobals
|
473
472
|
);
|
474
473
|
}
|
475
474
|
|
@@ -8,7 +8,7 @@
|
|
8
8
|
// Requirements
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
const astUtils = require("../ast-utils");
|
11
|
+
const astUtils = require("../util/ast-utils");
|
12
12
|
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
// Rule Definition
|
@@ -8,7 +8,7 @@
|
|
8
8
|
// Requirements
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
const astUtils = require("../ast-utils");
|
11
|
+
const astUtils = require("../util/ast-utils");
|
12
12
|
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
// Rule Definition
|
@@ -8,7 +8,7 @@
|
|
8
8
|
// Requirements
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
const astUtils = require("../ast-utils");
|
11
|
+
const astUtils = require("../util/ast-utils");
|
12
12
|
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
// Rule Definition
|
package/lib/rules/brace-style.js
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
11
|
const LETTER_PATTERN = require("../util/patterns/letters");
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
// Helpers
|
@@ -10,7 +10,7 @@
|
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
12
|
const lodash = require("lodash");
|
13
|
-
const astUtils = require("../ast-utils");
|
13
|
+
const astUtils = require("../util/ast-utils");
|
14
14
|
|
15
15
|
//------------------------------------------------------------------------------
|
16
16
|
// Helpers
|
package/lib/rules/comma-style.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
-
const astUtils = require("../ast-utils");
|
8
|
+
const astUtils = require("../util/ast-utils");
|
9
9
|
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
// Rule Definition
|
@@ -58,7 +58,7 @@ module.exports = {
|
|
58
58
|
NewExpression: true
|
59
59
|
};
|
60
60
|
|
61
|
-
if (context.options.length === 2 && context.options[1]
|
61
|
+
if (context.options.length === 2 && Object.prototype.hasOwnProperty.call(context.options[1], "exceptions")) {
|
62
62
|
const keys = Object.keys(context.options[1].exceptions);
|
63
63
|
|
64
64
|
for (let i = 0; i < keys.length; i++) {
|
package/lib/rules/complexity.js
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
const lodash = require("lodash");
|
14
14
|
|
15
|
-
const astUtils = require("../ast-utils");
|
15
|
+
const astUtils = require("../util/ast-utils");
|
16
16
|
|
17
17
|
//------------------------------------------------------------------------------
|
18
18
|
// Rule Definition
|
@@ -61,10 +61,10 @@ module.exports = {
|
|
61
61
|
const option = context.options[0];
|
62
62
|
let THRESHOLD = 20;
|
63
63
|
|
64
|
-
if (typeof option === "object" &&
|
64
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") {
|
65
65
|
THRESHOLD = option.maximum;
|
66
66
|
}
|
67
|
-
if (typeof option === "object" &&
|
67
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
|
68
68
|
THRESHOLD = option.max;
|
69
69
|
}
|
70
70
|
if (typeof option === "number") {
|
package/lib/rules/curly.js
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
// Requirements
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
const astUtils = require("../ast-utils");
|
11
|
+
const astUtils = require("../util/ast-utils");
|
12
12
|
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
// Rule Definition
|
@@ -8,7 +8,7 @@
|
|
8
8
|
// Requirements
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
const astUtils = require("../ast-utils");
|
11
|
+
const astUtils = require("../util/ast-utils");
|
12
12
|
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
// Rule Definition
|
package/lib/rules/eqeqeq.js
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
// Rule Definition
|
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
// Rule Definition
|
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//--------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
const esutils = require("esutils");
|
14
14
|
|
15
15
|
//--------------------------------------------------------------------------
|
package/lib/rules/func-names.js
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
|
14
14
|
/**
|
15
15
|
* Checks whether or not a given variable is a function name.
|
@@ -8,7 +8,7 @@
|
|
8
8
|
// Requirements
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
const astUtils = require("../ast-utils");
|
11
|
+
const astUtils = require("../util/ast-utils");
|
12
12
|
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
// Rule Definition
|
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
// Helpers
|
@@ -12,7 +12,7 @@
|
|
12
12
|
// Requirements
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
|
15
|
-
const astUtils = require("../ast-utils");
|
15
|
+
const astUtils = require("../util/ast-utils");
|
16
16
|
|
17
17
|
//------------------------------------------------------------------------------
|
18
18
|
// Rule Definition
|