summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/lib/cli-engine
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/lib/cli-engine')
-rw-r--r--tools/node_modules/eslint/lib/cli-engine/cli-engine.js7
-rw-r--r--tools/node_modules/eslint/lib/cli-engine/config-array-factory.js2
-rw-r--r--tools/node_modules/eslint/lib/cli-engine/file-enumerator.js18
-rw-r--r--tools/node_modules/eslint/lib/cli-engine/naming.js97
4 files changed, 11 insertions, 113 deletions
diff --git a/tools/node_modules/eslint/lib/cli-engine/cli-engine.js b/tools/node_modules/eslint/lib/cli-engine/cli-engine.js
index 81e1b07c83..7f80887f08 100644
--- a/tools/node_modules/eslint/lib/cli-engine/cli-engine.js
+++ b/tools/node_modules/eslint/lib/cli-engine/cli-engine.js
@@ -20,6 +20,7 @@ const path = require("path");
const defaultOptions = require("../../conf/default-cli-options");
const pkg = require("../../package.json");
const ConfigOps = require("../shared/config-ops");
+const naming = require("../shared/naming");
const ModuleResolver = require("../shared/relative-module-resolver");
const { Linter } = require("../linter");
const builtInRules = require("../rules");
@@ -29,7 +30,6 @@ const { FileEnumerator } = require("./file-enumerator");
const hash = require("./hash");
const { IgnoredPaths } = require("./ignored-paths");
const LintResultCache = require("./lint-result-cache");
-const naming = require("./naming");
const debug = require("debug")("eslint:cli-engine");
const validFixTypes = new Set(["problem", "suggestion", "layout"]);
@@ -734,7 +734,10 @@ class CLIEngine {
try {
fs.unlinkSync(cacheFilePath);
} catch (error) {
- if (!error || error.code !== "ENOENT") {
+ const errorCode = error && error.code;
+
+ // Ignore errors when no such file exists or file system is read only (and cache file does not exist)
+ if (errorCode !== "ENOENT" && !(errorCode === "EROFS" && !fs.existsSync(cacheFilePath))) {
throw error;
}
}
diff --git a/tools/node_modules/eslint/lib/cli-engine/config-array-factory.js b/tools/node_modules/eslint/lib/cli-engine/config-array-factory.js
index 782bb1d148..95430c358d 100644
--- a/tools/node_modules/eslint/lib/cli-engine/config-array-factory.js
+++ b/tools/node_modules/eslint/lib/cli-engine/config-array-factory.js
@@ -38,9 +38,9 @@ const path = require("path");
const importFresh = require("import-fresh");
const stripComments = require("strip-json-comments");
const { validateConfigSchema } = require("../shared/config-validator");
+const naming = require("../shared/naming");
const ModuleResolver = require("../shared/relative-module-resolver");
const { ConfigArray, ConfigDependency, OverrideTester } = require("./config-array");
-const naming = require("./naming");
const debug = require("debug")("eslint:config-array-factory");
//------------------------------------------------------------------------------
diff --git a/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js b/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js
index 2840d9fe2d..a027359ae5 100644
--- a/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js
+++ b/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js
@@ -292,26 +292,18 @@ class FileEnumerator {
_iterateFiles(pattern) {
const { cwd, globInputPaths } = internalSlotsMap.get(this);
const absolutePath = path.resolve(cwd, pattern);
-
- if (globInputPaths && isGlobPattern(pattern)) {
- return this._iterateFilesWithGlob(
- absolutePath,
- dotfilesPattern.test(pattern)
- );
- }
-
+ const isDot = dotfilesPattern.test(pattern);
const stat = statSafeSync(absolutePath);
if (stat && stat.isDirectory()) {
- return this._iterateFilesWithDirectory(
- absolutePath,
- dotfilesPattern.test(pattern)
- );
+ return this._iterateFilesWithDirectory(absolutePath, isDot);
}
-
if (stat && stat.isFile()) {
return this._iterateFilesWithFile(absolutePath);
}
+ if (globInputPaths && isGlobPattern(pattern)) {
+ return this._iterateFilesWithGlob(absolutePath, isDot);
+ }
return [];
}
diff --git a/tools/node_modules/eslint/lib/cli-engine/naming.js b/tools/node_modules/eslint/lib/cli-engine/naming.js
deleted file mode 100644
index b99155f15c..0000000000
--- a/tools/node_modules/eslint/lib/cli-engine/naming.js
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * @fileoverview Common helpers for naming of plugins, formatters and configs
- */
-"use strict";
-
-const NAMESPACE_REGEX = /^@.*\//iu;
-
-/**
- * Brings package name to correct format based on prefix
- * @param {string} name The name of the package.
- * @param {string} prefix Can be either "eslint-plugin", "eslint-config" or "eslint-formatter"
- * @returns {string} Normalized name of the package
- * @private
- */
-function normalizePackageName(name, prefix) {
- let normalizedName = name;
-
- /**
- * On Windows, name can come in with Windows slashes instead of Unix slashes.
- * Normalize to Unix first to avoid errors later on.
- * https://github.com/eslint/eslint/issues/5644
- */
- if (normalizedName.includes("\\")) {
- normalizedName = normalizedName.replace(/\\/gu, "/");
- }
-
- if (normalizedName.charAt(0) === "@") {
-
- /**
- * it's a scoped package
- * package name is the prefix, or just a username
- */
- const scopedPackageShortcutRegex = new RegExp(`^(@[^/]+)(?:/(?:${prefix})?)?$`, "u"),
- scopedPackageNameRegex = new RegExp(`^${prefix}(-|$)`, "u");
-
- if (scopedPackageShortcutRegex.test(normalizedName)) {
- normalizedName = normalizedName.replace(scopedPackageShortcutRegex, `$1/${prefix}`);
- } else if (!scopedPackageNameRegex.test(normalizedName.split("/")[1])) {
-
- /**
- * for scoped packages, insert the prefix after the first / unless
- * the path is already @scope/eslint or @scope/eslint-xxx-yyy
- */
- normalizedName = normalizedName.replace(/^@([^/]+)\/(.*)$/u, `@$1/${prefix}-$2`);
- }
- } else if (!normalizedName.startsWith(`${prefix}-`)) {
- normalizedName = `${prefix}-${normalizedName}`;
- }
-
- return normalizedName;
-}
-
-/**
- * Removes the prefix from a fullname.
- * @param {string} fullname The term which may have the prefix.
- * @param {string} prefix The prefix to remove.
- * @returns {string} The term without prefix.
- */
-function getShorthandName(fullname, prefix) {
- if (fullname[0] === "@") {
- let matchResult = new RegExp(`^(@[^/]+)/${prefix}$`, "u").exec(fullname);
-
- if (matchResult) {
- return matchResult[1];
- }
-
- matchResult = new RegExp(`^(@[^/]+)/${prefix}-(.+)$`, "u").exec(fullname);
- if (matchResult) {
- return `${matchResult[1]}/${matchResult[2]}`;
- }
- } else if (fullname.startsWith(`${prefix}-`)) {
- return fullname.slice(prefix.length + 1);
- }
-
- return fullname;
-}
-
-/**
- * Gets the scope (namespace) of a term.
- * @param {string} term The term which may have the namespace.
- * @returns {string} The namepace of the term if it has one.
- */
-function getNamespaceFromTerm(term) {
- const match = term.match(NAMESPACE_REGEX);
-
- return match ? match[0] : "";
-}
-
-//------------------------------------------------------------------------------
-// Public Interface
-//------------------------------------------------------------------------------
-
-module.exports = {
- normalizePackageName,
- getShorthandName,
- getNamespaceFromTerm
-};