eslint 6.0.0-alpha.1 → 6.0.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 +71 -0
- package/README.md +28 -21
- package/bin/eslint.js +2 -2
- package/conf/config-schema.js +38 -31
- package/conf/environments.js +1 -1
- package/conf/eslint-all.js +2 -2
- package/conf/eslint-recommended.js +1 -1
- package/lib/api.js +7 -3
- package/lib/cli-engine/cascading-config-array-factory.js +20 -8
- package/lib/{cli-engine.js → cli-engine/cli-engine.js} +44 -21
- package/lib/cli-engine/config-array/config-array.js +7 -8
- package/lib/cli-engine/config-array/config-dependency.js +2 -2
- package/lib/cli-engine/config-array/extracted-config.js +3 -3
- package/lib/cli-engine/config-array/override-tester.js +11 -1
- package/lib/cli-engine/config-array-factory.js +75 -65
- package/lib/cli-engine/file-enumerator.js +14 -6
- package/lib/{formatters → cli-engine/formatters}/checkstyle.js +1 -1
- package/lib/{formatters → cli-engine/formatters}/codeframe.js +0 -0
- package/lib/{formatters → cli-engine/formatters}/compact.js +0 -0
- package/lib/{formatters → cli-engine/formatters}/html-template-message.html +0 -0
- package/lib/{formatters → cli-engine/formatters}/html-template-page.html +0 -0
- package/lib/{formatters → cli-engine/formatters}/html-template-result.html +0 -0
- package/lib/{formatters → cli-engine/formatters}/html.js +0 -0
- package/lib/{formatters → cli-engine/formatters}/jslint-xml.js +1 -1
- package/lib/{formatters → cli-engine/formatters}/json-with-metadata.js +0 -0
- package/lib/{formatters → cli-engine/formatters}/json.js +0 -0
- package/lib/{formatters → cli-engine/formatters}/junit.js +15 -3
- package/lib/{formatters → cli-engine/formatters}/stylish.js +0 -0
- package/lib/{formatters → cli-engine/formatters}/table.js +0 -0
- package/lib/{formatters → cli-engine/formatters}/tap.js +0 -0
- package/lib/{formatters → cli-engine/formatters}/unix.js +0 -0
- package/lib/{formatters → cli-engine/formatters}/visualstudio.js +0 -0
- package/lib/{util → cli-engine}/hash.js +0 -0
- package/lib/{util → cli-engine}/ignored-paths.js +6 -1
- package/lib/cli-engine/index.js +7 -0
- package/lib/{util → cli-engine}/lint-result-cache.js +0 -0
- package/lib/{load-rules.js → cli-engine/load-rules.js} +0 -0
- package/lib/{util → cli-engine}/naming.js +0 -0
- package/lib/{util → cli-engine}/xml-escape.js +0 -0
- package/lib/cli.js +3 -3
- package/lib/{config → init}/autoconfig.js +3 -3
- package/lib/{config → init}/config-file.js +0 -0
- package/lib/{config → init}/config-initializer.js +6 -6
- package/lib/{config → init}/config-rule.js +8 -2
- package/lib/{util → init}/npm-utils.js +1 -1
- package/lib/{util → init}/source-code-utils.js +16 -1
- package/lib/{util → linter}/apply-disable-directives.js +0 -0
- package/lib/{code-path-analysis → linter/code-path-analysis}/code-path-analyzer.js +19 -6
- package/lib/{code-path-analysis → linter/code-path-analysis}/code-path-segment.js +0 -0
- package/lib/{code-path-analysis → linter/code-path-analysis}/code-path-state.js +0 -0
- package/lib/{code-path-analysis → linter/code-path-analysis}/code-path.js +0 -0
- package/lib/{code-path-analysis → linter/code-path-analysis}/debug-helpers.js +0 -0
- package/lib/{code-path-analysis → linter/code-path-analysis}/fork-context.js +0 -0
- package/lib/{code-path-analysis → linter/code-path-analysis}/id-generator.js +0 -0
- package/lib/{util → linter}/config-comment-parser.js +1 -1
- package/lib/linter/index.js +13 -0
- package/lib/{util → linter}/interpolate.js +0 -0
- package/lib/{linter.js → linter/linter.js} +298 -152
- package/lib/{util → linter}/node-event-generator.js +7 -5
- package/lib/{util → linter}/report-translator.js +0 -0
- package/lib/{util → linter}/rule-fixer.js +0 -0
- package/lib/{rules.js → linter/rules.js} +3 -29
- package/lib/{util → linter}/safe-emitter.js +0 -0
- package/lib/{util → linter}/source-code-fixer.js +0 -0
- package/lib/{util → linter}/timing.js +1 -1
- package/lib/rule-tester/index.js +5 -0
- package/lib/{testers → rule-tester}/rule-tester.js +43 -15
- 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 +22 -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 +2 -2
- package/lib/rules/comma-dangle.js +1 -1
- package/lib/rules/comma-spacing.js +1 -1
- package/lib/rules/comma-style.js +1 -1
- 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 +2 -2
- 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/implicit-arrow-linebreak.js +1 -1
- package/lib/rules/indent-legacy.js +1 -1
- package/lib/rules/indent.js +1 -1
- package/lib/rules/index.js +281 -0
- package/lib/rules/jsx-quotes.js +1 -1
- package/lib/rules/key-spacing.js +1 -1
- package/lib/rules/keyword-spacing.js +2 -2
- package/lib/rules/line-comment-position.js +1 -1
- 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-classes-per-file.js +2 -1
- package/lib/rules/max-depth.js +2 -2
- package/lib/rules/max-len.js +11 -4
- package/lib/rules/max-lines-per-function.js +4 -2
- package/lib/rules/max-lines.js +2 -2
- package/lib/rules/max-params.js +1 -1
- package/lib/rules/max-statements-per-line.js +1 -1
- package/lib/rules/max-statements.js +1 -1
- package/lib/rules/multiline-comment-style.js +3 -2
- package/lib/rules/multiline-ternary.js +1 -1
- package/lib/rules/new-parens.js +43 -11
- 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-catch-shadow.js +1 -1
- 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-div-regex.js +9 -1
- package/lib/rules/no-dupe-keys.js +1 -1
- package/lib/rules/no-else-return.js +129 -2
- 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 +1 -1
- package/lib/rules/no-extra-semi.js +2 -2
- 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 +1 -1
- 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-octal.js +1 -1
- package/lib/rules/no-redeclare.js +1 -1
- package/lib/rules/no-regex-spaces.js +1 -1
- package/lib/rules/no-restricted-imports.js +18 -14
- 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 -2
- 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 +7 -2
- package/lib/rules/no-useless-return.js +2 -2
- package/lib/rules/no-var.js +15 -2
- 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/operator-assignment.js +1 -1
- package/lib/rules/operator-linebreak.js +1 -1
- package/lib/rules/padded-blocks.js +1 -1
- package/lib/rules/padding-line-between-statements.js +1 -1
- package/lib/rules/prefer-const.js +1 -1
- package/lib/rules/prefer-object-spread.js +1 -1
- package/lib/rules/prefer-promise-reject-errors.js +1 -1
- package/lib/rules/prefer-spread.js +1 -1
- package/lib/rules/prefer-template.js +1 -1
- package/lib/rules/quote-props.js +1 -1
- package/lib/rules/quotes.js +1 -1
- package/lib/rules/radix.js +1 -1
- package/lib/rules/require-atomic-updates.js +63 -84
- package/lib/rules/require-await.js +1 -1
- package/lib/rules/semi-spacing.js +1 -1
- package/lib/rules/semi-style.js +1 -1
- package/lib/rules/semi.js +2 -2
- package/lib/rules/sort-keys.js +12 -4
- 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 +1 -1
- 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/{util → rules/utils}/ast-utils.js +8 -27
- package/lib/{util → rules/utils}/fix-tracker.js +1 -1
- package/lib/{util → rules/utils}/keywords.js +0 -0
- package/lib/{util → rules/utils}/lazy-loading-rule-map.js +0 -0
- package/lib/{util → rules/utils}/patterns/letters.js +0 -0
- package/lib/{util → rules/utils}/unicode/index.js +0 -0
- package/lib/{util → rules/utils}/unicode/is-combining-character.js +0 -0
- package/lib/{util → rules/utils}/unicode/is-emoji-modifier.js +0 -0
- package/lib/{util → rules/utils}/unicode/is-regional-indicator-symbol.js +0 -0
- package/lib/{util → rules/utils}/unicode/is-surrogate-pair.js +0 -0
- package/lib/rules/valid-typeof.js +1 -1
- package/lib/rules/wrap-iife.js +1 -1
- package/lib/rules/yoda.js +1 -1
- package/lib/{util → shared}/ajv.js +0 -0
- package/lib/shared/ast-utils.js +29 -0
- package/lib/{config → shared}/config-ops.js +0 -0
- package/lib/{config → shared}/config-validator.js +22 -7
- package/lib/{util → shared}/logging.js +0 -0
- package/lib/{util → shared}/relative-module-resolver.js +10 -3
- package/lib/{util → shared}/traverser.js +0 -0
- package/lib/{util → shared}/types.js +4 -0
- package/lib/source-code/index.js +5 -0
- package/lib/{util → source-code}/source-code.js +10 -8
- package/lib/{token-store → source-code/token-store}/backward-token-comment-cursor.js +0 -0
- package/lib/{token-store → source-code/token-store}/backward-token-cursor.js +0 -0
- package/lib/{token-store → source-code/token-store}/cursor.js +0 -0
- package/lib/{token-store → source-code/token-store}/cursors.js +0 -0
- package/lib/{token-store → source-code/token-store}/decorative-cursor.js +0 -0
- package/lib/{token-store → source-code/token-store}/filter-cursor.js +0 -0
- package/lib/{token-store → source-code/token-store}/forward-token-comment-cursor.js +0 -0
- package/lib/{token-store → source-code/token-store}/forward-token-cursor.js +0 -0
- package/lib/{token-store → source-code/token-store}/index.js +3 -3
- package/lib/{token-store → source-code/token-store}/limit-cursor.js +0 -0
- package/lib/{token-store → source-code/token-store}/padded-token-cursor.js +0 -0
- package/lib/{token-store → source-code/token-store}/skip-cursor.js +0 -0
- package/lib/{token-store → source-code/token-store}/utils.js +0 -0
- package/messages/extend-config-missing.txt +2 -0
- package/messages/print-config-with-directory-path.txt +2 -0
- package/package.json +8 -11
- package/lib/built-in-rules-index.js +0 -281
@@ -108,7 +108,7 @@ class ConfigDependency {
|
|
108
108
|
}
|
109
109
|
}
|
110
110
|
|
111
|
-
/** @typedef {ConfigDependency<import("../../
|
112
|
-
/** @typedef {ConfigDependency<import("../../
|
111
|
+
/** @typedef {ConfigDependency<import("../../shared/types").Parser>} DependentParser */
|
112
|
+
/** @typedef {ConfigDependency<import("../../shared/types").Plugin>} DependentPlugin */
|
113
113
|
|
114
114
|
module.exports = { ConfigDependency };
|
@@ -17,9 +17,9 @@
|
|
17
17
|
"use strict";
|
18
18
|
|
19
19
|
// For VSCode intellisense
|
20
|
-
/** @typedef {import("../../
|
21
|
-
/** @typedef {import("../../
|
22
|
-
/** @typedef {import("../../
|
20
|
+
/** @typedef {import("../../shared/types").ConfigData} ConfigData */
|
21
|
+
/** @typedef {import("../../shared/types").GlobalConf} GlobalConf */
|
22
|
+
/** @typedef {import("../../shared/types").SeverityConf} SeverityConf */
|
23
23
|
/** @typedef {import("./config-dependency").DependentParser} DependentParser */
|
24
24
|
/** @typedef {import("./config-dependency").DependentPlugin} DependentPlugin */
|
25
25
|
|
@@ -55,7 +55,17 @@ function toMatcher(patterns) {
|
|
55
55
|
if (patterns.length === 0) {
|
56
56
|
return null;
|
57
57
|
}
|
58
|
-
return patterns.map(pattern =>
|
58
|
+
return patterns.map(pattern => {
|
59
|
+
if (/^\.[/\\]/u.test(pattern)) {
|
60
|
+
return new Minimatch(
|
61
|
+
pattern.slice(2),
|
62
|
+
|
63
|
+
// `./*.js` should not match with `subdir/foo.js`
|
64
|
+
{ ...minimatchOpts, matchBase: false }
|
65
|
+
);
|
66
|
+
}
|
67
|
+
return new Minimatch(pattern, minimatchOpts);
|
68
|
+
});
|
59
69
|
}
|
60
70
|
|
61
71
|
/**
|
@@ -37,10 +37,10 @@ const fs = require("fs");
|
|
37
37
|
const path = require("path");
|
38
38
|
const importFresh = require("import-fresh");
|
39
39
|
const stripComments = require("strip-json-comments");
|
40
|
-
const { validateConfigSchema } = require("../
|
40
|
+
const { validateConfigSchema } = require("../shared/config-validator");
|
41
|
+
const ModuleResolver = require("../shared/relative-module-resolver");
|
41
42
|
const { ConfigArray, ConfigDependency, OverrideTester } = require("./config-array");
|
42
|
-
const
|
43
|
-
const naming = require("../util/naming");
|
43
|
+
const naming = require("./naming");
|
44
44
|
const debug = require("debug")("eslint:config-array-factory");
|
45
45
|
|
46
46
|
//------------------------------------------------------------------------------
|
@@ -59,10 +59,10 @@ const configFilenames = [
|
|
59
59
|
];
|
60
60
|
|
61
61
|
// Define types for VSCode IntelliSense.
|
62
|
-
/** @typedef {import("../
|
63
|
-
/** @typedef {import("../
|
64
|
-
/** @typedef {import("../
|
65
|
-
/** @typedef {import("../
|
62
|
+
/** @typedef {import("../shared/types").ConfigData} ConfigData */
|
63
|
+
/** @typedef {import("../shared/types").OverrideConfigData} OverrideConfigData */
|
64
|
+
/** @typedef {import("../shared/types").Parser} Parser */
|
65
|
+
/** @typedef {import("../shared/types").Plugin} Plugin */
|
66
66
|
/** @typedef {import("./config-array/config-dependency").DependentParser} DependentParser */
|
67
67
|
/** @typedef {import("./config-array/config-dependency").DependentPlugin} DependentPlugin */
|
68
68
|
/** @typedef {ConfigArray[0]} ConfigArrayElement */
|
@@ -224,15 +224,16 @@ function loadPackageJSONConfigFile(filePath) {
|
|
224
224
|
/**
|
225
225
|
* Creates an error to notify about a missing config to extend from.
|
226
226
|
* @param {string} configName The name of the missing config.
|
227
|
+
* @param {string} importerName The name of the config that imported the missing config
|
227
228
|
* @returns {Error} The error object to throw
|
228
229
|
* @private
|
229
230
|
*/
|
230
|
-
function configMissingError(configName) {
|
231
|
+
function configMissingError(configName, importerName) {
|
231
232
|
return Object.assign(
|
232
233
|
new Error(`Failed to load config "${configName}" to extend from.`),
|
233
234
|
{
|
234
235
|
messageTemplate: "extend-config-missing",
|
235
|
-
messageData: { configName }
|
236
|
+
messageData: { configName, importerName }
|
236
237
|
}
|
237
238
|
);
|
238
239
|
}
|
@@ -427,28 +428,22 @@ class ConfigArrayFactory {
|
|
427
428
|
_loadConfigDataInDirectory(directoryPath, name) {
|
428
429
|
for (const filename of configFilenames) {
|
429
430
|
const filePath = path.join(directoryPath, filename);
|
430
|
-
const originalDebugEnabled = debug.enabled;
|
431
|
-
let configData;
|
432
431
|
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
error.code !== "
|
440
|
-
|
441
|
-
|
442
|
-
) {
|
443
|
-
throw error;
|
432
|
+
if (fs.existsSync(filePath)) {
|
433
|
+
let configData;
|
434
|
+
|
435
|
+
try {
|
436
|
+
configData = loadConfigFile(filePath);
|
437
|
+
} catch (error) {
|
438
|
+
if (!error || error.code !== "ESLINT_CONFIG_FIELD_NOT_FOUND") {
|
439
|
+
throw error;
|
440
|
+
}
|
444
441
|
}
|
445
|
-
} finally {
|
446
|
-
debug.enabled = originalDebugEnabled;
|
447
|
-
}
|
448
442
|
|
449
|
-
|
450
|
-
|
451
|
-
|
443
|
+
if (configData) {
|
444
|
+
debug(`Config file found: ${filePath}`);
|
445
|
+
return this._normalizeConfigData(configData, filePath, name);
|
446
|
+
}
|
452
447
|
}
|
453
448
|
}
|
454
449
|
|
@@ -506,6 +501,14 @@ class ConfigArrayFactory {
|
|
506
501
|
*/
|
507
502
|
element.criteria = OverrideTester.and(criteria, element.criteria);
|
508
503
|
|
504
|
+
/*
|
505
|
+
* Remove `root` property to ignore `root` settings which came from
|
506
|
+
* `extends` in `overrides`.
|
507
|
+
*/
|
508
|
+
if (element.criteria) {
|
509
|
+
element.root = void 0;
|
510
|
+
}
|
511
|
+
|
509
512
|
yield element;
|
510
513
|
}
|
511
514
|
}
|
@@ -526,7 +529,7 @@ class ConfigArrayFactory {
|
|
526
529
|
parser: parserName,
|
527
530
|
parserOptions,
|
528
531
|
plugins: pluginList,
|
529
|
-
processor,
|
532
|
+
processor,
|
530
533
|
root,
|
531
534
|
rules,
|
532
535
|
settings,
|
@@ -635,7 +638,7 @@ class ConfigArrayFactory {
|
|
635
638
|
return this._loadConfigData(eslintAllPath, name);
|
636
639
|
}
|
637
640
|
|
638
|
-
throw configMissingError(extendName);
|
641
|
+
throw configMissingError(extendName, importerName);
|
639
642
|
}
|
640
643
|
|
641
644
|
/**
|
@@ -668,7 +671,7 @@ class ConfigArrayFactory {
|
|
668
671
|
);
|
669
672
|
}
|
670
673
|
|
671
|
-
throw plugin.error || configMissingError(extendName);
|
674
|
+
throw plugin.error || configMissingError(extendName, importerPath);
|
672
675
|
}
|
673
676
|
|
674
677
|
/**
|
@@ -695,20 +698,20 @@ class ConfigArrayFactory {
|
|
695
698
|
);
|
696
699
|
}
|
697
700
|
|
698
|
-
|
699
|
-
const filePath = ModuleResolver.resolve(request, relativeTo);
|
700
|
-
|
701
|
-
writeDebugLogForLoading(request, relativeTo, filePath);
|
701
|
+
let filePath;
|
702
702
|
|
703
|
-
|
703
|
+
try {
|
704
|
+
filePath = ModuleResolver.resolve(request, relativeTo);
|
704
705
|
} catch (error) {
|
705
|
-
/* istanbul ignore
|
706
|
-
if (
|
707
|
-
throw
|
706
|
+
/* istanbul ignore else */
|
707
|
+
if (error && error.code === "MODULE_NOT_FOUND") {
|
708
|
+
throw configMissingError(extendName, importerPath);
|
708
709
|
}
|
710
|
+
throw error;
|
709
711
|
}
|
710
712
|
|
711
|
-
|
713
|
+
writeDebugLogForLoading(request, relativeTo, filePath);
|
714
|
+
return this._loadConfigData(filePath, `${importerName} » ${request}`);
|
712
715
|
}
|
713
716
|
|
714
717
|
/**
|
@@ -797,6 +800,7 @@ class ConfigArrayFactory {
|
|
797
800
|
const { additionalPluginPool, resolvePluginsRelativeTo } = internalSlotsMap.get(this);
|
798
801
|
const request = naming.normalizePackageName(name, "eslint-plugin");
|
799
802
|
const id = naming.getShorthandName(request, "eslint-plugin");
|
803
|
+
const relativeTo = path.join(resolvePluginsRelativeTo, "__placeholder__.js");
|
800
804
|
|
801
805
|
if (name.match(/\s+/u)) {
|
802
806
|
const error = Object.assign(
|
@@ -830,25 +834,15 @@ class ConfigArrayFactory {
|
|
830
834
|
});
|
831
835
|
}
|
832
836
|
|
833
|
-
|
834
|
-
|
835
|
-
// Resolve the plugin file
|
836
|
-
const relativeTo = path.join(resolvePluginsRelativeTo, "__placeholder__.js");
|
837
|
-
const filePath = ModuleResolver.resolve(request, relativeTo);
|
838
|
-
|
839
|
-
writeDebugLogForLoading(request, relativeTo, filePath);
|
840
|
-
|
841
|
-
return new ConfigDependency({
|
842
|
-
definition: normalizePlugin(require(filePath)),
|
843
|
-
filePath,
|
844
|
-
id,
|
845
|
-
importerName,
|
846
|
-
importerPath
|
847
|
-
});
|
848
|
-
} catch (error) {
|
849
|
-
debug("Failed to load plugin '%s' declared in '%s'.", name, importerName);
|
837
|
+
let filePath;
|
838
|
+
let error;
|
850
839
|
|
851
|
-
|
840
|
+
try {
|
841
|
+
filePath = ModuleResolver.resolve(request, relativeTo);
|
842
|
+
} catch (resolveError) {
|
843
|
+
error = resolveError;
|
844
|
+
/* istanbul ignore else */
|
845
|
+
if (error && error.code === "MODULE_NOT_FOUND") {
|
852
846
|
error.messageTemplate = "plugin-missing";
|
853
847
|
error.messageData = {
|
854
848
|
pluginName: request,
|
@@ -856,15 +850,31 @@ class ConfigArrayFactory {
|
|
856
850
|
importerName
|
857
851
|
};
|
858
852
|
}
|
859
|
-
|
853
|
+
}
|
860
854
|
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
855
|
+
if (filePath) {
|
856
|
+
try {
|
857
|
+
writeDebugLogForLoading(request, relativeTo, filePath);
|
858
|
+
return new ConfigDependency({
|
859
|
+
definition: normalizePlugin(require(filePath)),
|
860
|
+
filePath,
|
861
|
+
id,
|
862
|
+
importerName,
|
863
|
+
importerPath
|
864
|
+
});
|
865
|
+
} catch (loadError) {
|
866
|
+
error = loadError;
|
867
|
+
}
|
867
868
|
}
|
869
|
+
|
870
|
+
debug("Failed to load plugin '%s' declared in '%s'.", name, importerName);
|
871
|
+
error.message = `Failed to load plugin '${name}' declared in '${importerName}': ${error.message}`;
|
872
|
+
return new ConfigDependency({
|
873
|
+
error,
|
874
|
+
id,
|
875
|
+
importerName,
|
876
|
+
importerPath
|
877
|
+
});
|
868
878
|
}
|
869
879
|
|
870
880
|
/**
|
@@ -41,7 +41,7 @@ const isGlob = require("is-glob");
|
|
41
41
|
const { escapeRegExp } = require("lodash");
|
42
42
|
const { Minimatch } = require("minimatch");
|
43
43
|
const { CascadingConfigArrayFactory } = require("./cascading-config-array-factory");
|
44
|
-
const { IgnoredPaths } = require("
|
44
|
+
const { IgnoredPaths } = require("./ignored-paths");
|
45
45
|
const debug = require("debug")("eslint:file-enumerator");
|
46
46
|
|
47
47
|
//------------------------------------------------------------------------------
|
@@ -89,7 +89,7 @@ const IGNORED = 2;
|
|
89
89
|
* @typedef {Object} FileEnumeratorInternalSlots
|
90
90
|
* @property {CascadingConfigArrayFactory} configArrayFactory The factory for config arrays.
|
91
91
|
* @property {string} cwd The base directory to start lookup.
|
92
|
-
* @property {RegExp}
|
92
|
+
* @property {RegExp} extensionRegExp The RegExp to test if a string ends with specific file extensions.
|
93
93
|
* @property {boolean} globInputPaths Set to false to skip glob resolution of input file paths to lint (default: true). If false, each input file paths is assumed to be a non-glob path to an existing file.
|
94
94
|
* @property {boolean} ignoreFlag The flag to check ignored files.
|
95
95
|
* @property {IgnoredPaths} ignoredPathsWithDotfiles The ignored paths but don't include dot files.
|
@@ -196,7 +196,7 @@ class FileEnumerator {
|
|
196
196
|
internalSlotsMap.set(this, {
|
197
197
|
configArrayFactory,
|
198
198
|
cwd,
|
199
|
-
|
199
|
+
extensionRegExp: new RegExp(
|
200
200
|
`.\\.(?:${extensions
|
201
201
|
.map(ext => escapeRegExp(
|
202
202
|
ext.startsWith(".")
|
@@ -217,6 +217,14 @@ class FileEnumerator {
|
|
217
217
|
});
|
218
218
|
}
|
219
219
|
|
220
|
+
/**
|
221
|
+
* The `RegExp` object that tests if a file path has the allowed file extensions.
|
222
|
+
* @type {RegExp}
|
223
|
+
*/
|
224
|
+
get extensionRegExp() {
|
225
|
+
return internalSlotsMap.get(this).extensionRegExp;
|
226
|
+
}
|
227
|
+
|
220
228
|
/**
|
221
229
|
* Iterate files which are matched by given glob patterns.
|
222
230
|
* @param {string|string[]} patternOrPatterns The glob patterns to iterate files.
|
@@ -380,11 +388,11 @@ class FileEnumerator {
|
|
380
388
|
* @private
|
381
389
|
*/
|
382
390
|
*_iterateFilesRecursive(directoryPath, options) {
|
383
|
-
if (this._isIgnoredFile(directoryPath, options)) {
|
391
|
+
if (this._isIgnoredFile(directoryPath + path.sep, options)) {
|
384
392
|
return;
|
385
393
|
}
|
386
394
|
debug(`Enter the directory: ${directoryPath}`);
|
387
|
-
const { configArrayFactory,
|
395
|
+
const { configArrayFactory, extensionRegExp } = internalSlotsMap.get(this);
|
388
396
|
|
389
397
|
/** @type {ConfigArray|null} */
|
390
398
|
let config = null;
|
@@ -407,7 +415,7 @@ class FileEnumerator {
|
|
407
415
|
? options.selector.match(filePath)
|
408
416
|
|
409
417
|
// Started with a directory path; choose by file extensions.
|
410
|
-
:
|
418
|
+
: extensionRegExp.test(filePath);
|
411
419
|
|
412
420
|
if (matched) {
|
413
421
|
debug(`Yield: ${filename}${ignored ? " but ignored" : ""}`);
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -4,7 +4,8 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
-
const xmlEscape = require("../
|
7
|
+
const xmlEscape = require("../xml-escape");
|
8
|
+
const path = require("path");
|
8
9
|
|
9
10
|
//------------------------------------------------------------------------------
|
10
11
|
// Helper Functions
|
@@ -24,6 +25,16 @@ function getMessageType(message) {
|
|
24
25
|
|
25
26
|
}
|
26
27
|
|
28
|
+
/**
|
29
|
+
* Returns a full file path without extension
|
30
|
+
* @param {string} filePath input file path
|
31
|
+
* @returns {string} file path without extension
|
32
|
+
* @private
|
33
|
+
*/
|
34
|
+
function pathWithoutExt(filePath) {
|
35
|
+
return path.posix.join(path.posix.dirname(filePath), path.basename(filePath, path.extname(filePath)));
|
36
|
+
}
|
37
|
+
|
27
38
|
//------------------------------------------------------------------------------
|
28
39
|
// Public Interface
|
29
40
|
//------------------------------------------------------------------------------
|
@@ -38,13 +49,14 @@ module.exports = function(results) {
|
|
38
49
|
results.forEach(result => {
|
39
50
|
|
40
51
|
const messages = result.messages;
|
52
|
+
const classname = pathWithoutExt(result.filePath);
|
41
53
|
|
42
54
|
if (messages.length > 0) {
|
43
55
|
output += `<testsuite package="org.eslint" time="0" tests="${messages.length}" errors="${messages.length}" name="${result.filePath}">\n`;
|
44
56
|
messages.forEach(message => {
|
45
57
|
const type = message.fatal ? "error" : "failure";
|
46
58
|
|
47
|
-
output += `<testcase time="0" name="org.eslint.${message.ruleId || "unknown"}">`;
|
59
|
+
output += `<testcase time="0" name="org.eslint.${message.ruleId || "unknown"}" classname="${classname}">`;
|
48
60
|
output += `<${type} message="${xmlEscape(message.message || "")}">`;
|
49
61
|
output += "<![CDATA[";
|
50
62
|
output += `line ${message.line || 0}, col `;
|
@@ -58,7 +70,7 @@ module.exports = function(results) {
|
|
58
70
|
output += "</testsuite>\n";
|
59
71
|
} else {
|
60
72
|
output += `<testsuite package="org.eslint" time="0" tests="1" errors="0" name="${result.filePath}">\n`;
|
61
|
-
output += `<testcase time="0" name="${result.filePath}" />\n`;
|
73
|
+
output += `<testcase time="0" name="${result.filePath}" classname="${classname}" />\n`;
|
62
74
|
output += "</testsuite>\n";
|
63
75
|
}
|
64
76
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -328,12 +328,17 @@ class IgnoredPaths {
|
|
328
328
|
* @returns {boolean} true if the file path matches one or more patterns, false otherwise
|
329
329
|
*/
|
330
330
|
contains(filepath, category) {
|
331
|
+
const isDir = filepath.endsWith(path.sep) ||
|
332
|
+
(path.sep === "\\" && filepath.endsWith("/"));
|
331
333
|
let result = false;
|
332
334
|
const basePath = this.getBaseDir();
|
333
335
|
const absolutePath = path.resolve(this.options.cwd, filepath);
|
334
|
-
|
336
|
+
let relativePath = path.relative(basePath, absolutePath);
|
335
337
|
|
336
338
|
if (relativePath) {
|
339
|
+
if (isDir) {
|
340
|
+
relativePath += path.sep;
|
341
|
+
}
|
337
342
|
if (typeof category === "undefined") {
|
338
343
|
result =
|
339
344
|
(this.ig.default.filter([relativePath]).length === 0) ||
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
package/lib/cli.js
CHANGED
@@ -17,10 +17,10 @@
|
|
17
17
|
|
18
18
|
const fs = require("fs"),
|
19
19
|
path = require("path"),
|
20
|
-
options = require("./options"),
|
21
|
-
CLIEngine = require("./cli-engine").CLIEngine,
|
22
20
|
mkdirp = require("mkdirp"),
|
23
|
-
|
21
|
+
{ CLIEngine } = require("./cli-engine"),
|
22
|
+
options = require("./options"),
|
23
|
+
log = require("./shared/logging");
|
24
24
|
|
25
25
|
const debug = require("debug")("eslint:cli");
|
26
26
|
|
@@ -10,10 +10,10 @@
|
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
12
|
const lodash = require("lodash"),
|
13
|
+
recConfig = require("../../conf/eslint-recommended"),
|
14
|
+
ConfigOps = require("../shared/config-ops"),
|
13
15
|
{ Linter } = require("../linter"),
|
14
|
-
configRule = require("./config-rule")
|
15
|
-
ConfigOps = require("./config-ops"),
|
16
|
-
recConfig = require("../../conf/eslint-recommended");
|
16
|
+
configRule = require("./config-rule");
|
17
17
|
|
18
18
|
const debug = require("debug")("eslint:autoconfig");
|
19
19
|
const linter = new Linter();
|
File without changes
|
@@ -15,14 +15,14 @@ const util = require("util"),
|
|
15
15
|
inquirer = require("inquirer"),
|
16
16
|
ProgressBar = require("progress"),
|
17
17
|
semver = require("semver"),
|
18
|
+
recConfig = require("../../conf/eslint-recommended"),
|
19
|
+
ConfigOps = require("../shared/config-ops"),
|
20
|
+
log = require("../shared/logging"),
|
21
|
+
ModuleResolver = require("../shared/relative-module-resolver"),
|
18
22
|
autoconfig = require("./autoconfig.js"),
|
19
23
|
ConfigFile = require("./config-file"),
|
20
|
-
|
21
|
-
{ getSourceCodeOfFiles } = require("
|
22
|
-
ModuleResolver = require("../util/relative-module-resolver"),
|
23
|
-
npmUtils = require("../util/npm-utils"),
|
24
|
-
recConfig = require("../../conf/eslint-recommended"),
|
25
|
-
log = require("../util/logging");
|
24
|
+
npmUtils = require("./npm-utils"),
|
25
|
+
{ getSourceCodeOfFiles } = require("./source-code-utils");
|
26
26
|
|
27
27
|
const debug = require("debug")("eslint:config-initializer");
|
28
28
|
|
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const builtInRules = require("../
|
12
|
+
const builtInRules = require("../rules");
|
13
13
|
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
// Helpers
|
@@ -293,11 +293,17 @@ function generateConfigsFromSchema(schema) {
|
|
293
293
|
|
294
294
|
/**
|
295
295
|
* Generate possible rule configurations for all of the core rules
|
296
|
+
* @param {boolean} noDeprecated Indicates whether ignores deprecated rules or not.
|
296
297
|
* @returns {rulesConfig} Hash of rule names and arrays of possible configurations
|
297
298
|
*/
|
298
|
-
function createCoreRuleConfigs() {
|
299
|
+
function createCoreRuleConfigs(noDeprecated = false) {
|
299
300
|
return Array.from(builtInRules).reduce((accumulator, [id, rule]) => {
|
300
301
|
const schema = (typeof rule === "function") ? rule.schema : rule.meta.schema;
|
302
|
+
const isDeprecated = (typeof rule === "function") ? rule.deprecated : rule.meta.deprecated;
|
303
|
+
|
304
|
+
if (noDeprecated && isDeprecated) {
|
305
|
+
return accumulator;
|
306
|
+
}
|
301
307
|
|
302
308
|
accumulator[id] = generateConfigsFromSchema(schema);
|
303
309
|
return accumulator;
|
@@ -12,7 +12,7 @@
|
|
12
12
|
const fs = require("fs"),
|
13
13
|
spawn = require("cross-spawn"),
|
14
14
|
path = require("path"),
|
15
|
-
log = require("
|
15
|
+
log = require("../shared/logging");
|
16
16
|
|
17
17
|
//------------------------------------------------------------------------------
|
18
18
|
// Helpers
|
@@ -9,7 +9,22 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const { CLIEngine
|
12
|
+
const { CLIEngine } = require("../cli-engine");
|
13
|
+
|
14
|
+
/*
|
15
|
+
* This is used for:
|
16
|
+
*
|
17
|
+
* 1. Enumerate target file because we have not expose such a API on `CLIEngine`
|
18
|
+
* (https://github.com/eslint/eslint/issues/11222).
|
19
|
+
* 2. Create `SourceCode` instances. Because we don't have any function which
|
20
|
+
* instantiate `SourceCode` so it needs to take the created `SourceCode`
|
21
|
+
* instance out after linting.
|
22
|
+
*
|
23
|
+
* TODO1: Expose the API that enumerates target files.
|
24
|
+
* TODO2: Extract the creation logic of `SourceCode` from `Linter` class.
|
25
|
+
*/
|
26
|
+
const { getCLIEngineInternalSlots } = require("../cli-engine/cli-engine"); // eslint-disable-line no-restricted-modules
|
27
|
+
|
13
28
|
const debug = require("debug")("eslint:source-code-utils");
|
14
29
|
|
15
30
|
//------------------------------------------------------------------------------
|
File without changes
|