Add components
This commit is contained in:
34
slider/node_modules/eslint/lib/shared/ajv.js
generated
vendored
Normal file
34
slider/node_modules/eslint/lib/shared/ajv.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @fileoverview The instance of Ajv validator.
|
||||
* @author Evgeny Poberezkin
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const Ajv = require("ajv"),
|
||||
metaSchema = require("ajv/lib/refs/json-schema-draft-04.json");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
module.exports = (additionalOptions = {}) => {
|
||||
const ajv = new Ajv({
|
||||
meta: false,
|
||||
useDefaults: true,
|
||||
validateSchema: false,
|
||||
missingRefs: "ignore",
|
||||
verbose: true,
|
||||
schemaId: "auto",
|
||||
...additionalOptions,
|
||||
});
|
||||
|
||||
ajv.addMetaSchema(metaSchema);
|
||||
// eslint-disable-next-line no-underscore-dangle -- Ajv's API
|
||||
ajv._opts.defaultMeta = metaSchema.id;
|
||||
|
||||
return ajv;
|
||||
};
|
21
slider/node_modules/eslint/lib/shared/assert.js
generated
vendored
Normal file
21
slider/node_modules/eslint/lib/shared/assert.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @fileoverview Assertion utilities equivalent to the Node.js node:asserts module.
|
||||
* @author Josh Goldberg
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Throws an error if the input is not truthy.
|
||||
* @param {unknown} value The input that is checked for being truthy.
|
||||
* @param {string} message Message to throw if the input is not truthy.
|
||||
* @returns {void}
|
||||
* @throws {Error} When the condition is not truthy.
|
||||
*/
|
||||
function ok(value, message = "Assertion failed.") {
|
||||
if (!value) {
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ok;
|
30
slider/node_modules/eslint/lib/shared/ast-utils.js
generated
vendored
Normal file
30
slider/node_modules/eslint/lib/shared/ast-utils.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @fileoverview Common utils for AST.
|
||||
*
|
||||
* This file contains only shared items for core and rules.
|
||||
* If you make a utility for rules, please see `../rules/utils/ast-utils.js`.
|
||||
*
|
||||
* @author Toru Nagashima <https://github.com/mysticatea>
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const breakableTypePattern =
|
||||
/^(?:(?:Do)?While|For(?:In|Of)?|Switch)Statement$/u;
|
||||
const lineBreakPattern = /\r\n|[\r\n\u2028\u2029]/u;
|
||||
const shebangPattern = /^#!([^\r\n]+)/u;
|
||||
|
||||
/**
|
||||
* Creates a version of the `lineBreakPattern` regex with the global flag.
|
||||
* Global regexes are mutable, so this needs to be a function instead of a constant.
|
||||
* @returns {RegExp} A global regular expression that matches line terminators
|
||||
*/
|
||||
function createGlobalLinebreakMatcher() {
|
||||
return new RegExp(lineBreakPattern.source, "gu");
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
breakableTypePattern,
|
||||
lineBreakPattern,
|
||||
createGlobalLinebreakMatcher,
|
||||
shebangPattern,
|
||||
};
|
62
slider/node_modules/eslint/lib/shared/deep-merge-arrays.js
generated
vendored
Normal file
62
slider/node_modules/eslint/lib/shared/deep-merge-arrays.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @fileoverview Applies default rule options
|
||||
* @author JoshuaKGoldberg
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Check if the variable contains an object strictly rejecting arrays
|
||||
* @param {unknown} value an object
|
||||
* @returns {boolean} Whether value is an object
|
||||
*/
|
||||
function isObjectNotArray(value) {
|
||||
return typeof value === "object" && value !== null && !Array.isArray(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deeply merges second on top of first, creating a new {} object if needed.
|
||||
* @param {T} first Base, default value.
|
||||
* @param {U} second User-specified value.
|
||||
* @returns {T | U | (T & U)} Merged equivalent of second on top of first.
|
||||
*/
|
||||
function deepMergeObjects(first, second) {
|
||||
if (second === void 0) {
|
||||
return first;
|
||||
}
|
||||
|
||||
if (!isObjectNotArray(first) || !isObjectNotArray(second)) {
|
||||
return second;
|
||||
}
|
||||
|
||||
const result = { ...first, ...second };
|
||||
|
||||
for (const key of Object.keys(second)) {
|
||||
if (Object.prototype.propertyIsEnumerable.call(first, key)) {
|
||||
result[key] = deepMergeObjects(first[key], second[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deeply merges second on top of first, creating a new [] array if needed.
|
||||
* @param {T[]} first Base, default values.
|
||||
* @param {U[]} second User-specified values.
|
||||
* @returns {(T | U | (T & U))[]} Merged equivalent of second on top of first.
|
||||
*/
|
||||
function deepMergeArrays(first, second) {
|
||||
if (!first || !second) {
|
||||
return second || first || [];
|
||||
}
|
||||
|
||||
return [
|
||||
...first.map((value, i) =>
|
||||
deepMergeObjects(value, i < second.length ? second[i] : void 0),
|
||||
),
|
||||
...second.slice(first.length),
|
||||
];
|
||||
}
|
||||
|
||||
module.exports = { deepMergeArrays };
|
16
slider/node_modules/eslint/lib/shared/directives.js
generated
vendored
Normal file
16
slider/node_modules/eslint/lib/shared/directives.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @fileoverview Common utils for directives.
|
||||
*
|
||||
* This file contains only shared items for directives.
|
||||
* If you make a utility for rules, please see `../rules/utils/ast-utils.js`.
|
||||
*
|
||||
* @author gfyoung <https://github.com/gfyoung>
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const directivesPattern =
|
||||
/^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u;
|
||||
|
||||
module.exports = {
|
||||
directivesPattern,
|
||||
};
|
108
slider/node_modules/eslint/lib/shared/flags.js
generated
vendored
Normal file
108
slider/node_modules/eslint/lib/shared/flags.js
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
* @fileoverview Shared flags for ESLint.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Typedefs
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @typedef {Object} InactiveFlagData
|
||||
* @property {string} description Flag description
|
||||
* @property {string | null} [replacedBy] Can be either:
|
||||
* - An active flag (string) that enables the same feature.
|
||||
* - `null` if the feature is now enabled by default.
|
||||
* - Omitted if the feature has been abandoned.
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The set of flags that change ESLint behavior with a description.
|
||||
* @type {Map<string, string>}
|
||||
*/
|
||||
const activeFlags = new Map([
|
||||
["test_only", "Used only for testing."],
|
||||
["test_only_2", "Used only for testing."],
|
||||
[
|
||||
"v10_config_lookup_from_file",
|
||||
"Look up `eslint.config.js` from the file being linted.",
|
||||
],
|
||||
[
|
||||
"unstable_native_nodejs_ts_config",
|
||||
"Use native Node.js to load TypeScript configuration.",
|
||||
],
|
||||
]);
|
||||
|
||||
/**
|
||||
* The set of flags that used to be active.
|
||||
* @type {Map<string, InactiveFlagData>}
|
||||
*/
|
||||
const inactiveFlags = new Map([
|
||||
[
|
||||
"test_only_replaced",
|
||||
{
|
||||
description:
|
||||
"Used only for testing flags that have been replaced by other flags.",
|
||||
replacedBy: "test_only",
|
||||
},
|
||||
],
|
||||
[
|
||||
"test_only_enabled_by_default",
|
||||
{
|
||||
description:
|
||||
"Used only for testing flags whose features have been enabled by default.",
|
||||
replacedBy: null,
|
||||
},
|
||||
],
|
||||
[
|
||||
"test_only_abandoned",
|
||||
{
|
||||
description:
|
||||
"Used only for testing flags whose features have been abandoned.",
|
||||
},
|
||||
],
|
||||
[
|
||||
"unstable_ts_config",
|
||||
{
|
||||
description: "Enable TypeScript configuration files.",
|
||||
replacedBy: null,
|
||||
},
|
||||
],
|
||||
[
|
||||
"unstable_config_lookup_from_file",
|
||||
{
|
||||
description:
|
||||
"Look up `eslint.config.js` from the file being linted.",
|
||||
replacedBy: "v10_config_lookup_from_file",
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
||||
/**
|
||||
* Creates a message that describes the reason the flag is inactive.
|
||||
* @param {InactiveFlagData} inactiveFlagData Data for the inactive flag.
|
||||
* @returns {string} Message describing the reason the flag is inactive.
|
||||
*/
|
||||
function getInactivityReasonMessage({ replacedBy }) {
|
||||
if (typeof replacedBy === "undefined") {
|
||||
return "This feature has been abandoned.";
|
||||
}
|
||||
|
||||
if (typeof replacedBy === "string") {
|
||||
return `This flag has been renamed '${replacedBy}' to reflect its stabilization. Please use '${replacedBy}' instead.`;
|
||||
}
|
||||
|
||||
// null
|
||||
return "This feature is now enabled by default.";
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
activeFlags,
|
||||
inactiveFlags,
|
||||
getInactivityReasonMessage,
|
||||
};
|
38
slider/node_modules/eslint/lib/shared/logging.js
generated
vendored
Normal file
38
slider/node_modules/eslint/lib/shared/logging.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @fileoverview Handle logging for ESLint
|
||||
* @author Gyandeep Singh
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/* eslint no-console: "off" -- Logging util */
|
||||
|
||||
/* c8 ignore next */
|
||||
module.exports = {
|
||||
/**
|
||||
* Cover for console.info
|
||||
* @param {...any} args The elements to log.
|
||||
* @returns {void}
|
||||
*/
|
||||
info(...args) {
|
||||
console.log(...args);
|
||||
},
|
||||
|
||||
/**
|
||||
* Cover for console.warn
|
||||
* @param {...any} args The elements to log.
|
||||
* @returns {void}
|
||||
*/
|
||||
warn(...args) {
|
||||
console.warn(...args);
|
||||
},
|
||||
|
||||
/**
|
||||
* Cover for console.error
|
||||
* @param {...any} args The elements to log.
|
||||
* @returns {void}
|
||||
*/
|
||||
error(...args) {
|
||||
console.error(...args);
|
||||
},
|
||||
};
|
109
slider/node_modules/eslint/lib/shared/naming.js
generated
vendored
Normal file
109
slider/node_modules/eslint/lib/shared/naming.js
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* @fileoverview Common helpers for naming of plugins, formatters and configs
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const NAMESPACE_REGEX = /^@.*\//u;
|
||||
|
||||
/**
|
||||
* 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 namespace 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,
|
||||
};
|
63
slider/node_modules/eslint/lib/shared/option-utils.js
generated
vendored
Normal file
63
slider/node_modules/eslint/lib/shared/option-utils.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @fileoverview Utilities to operate on option objects.
|
||||
* @author Josh Goldberg
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Determines whether any of input's properties are different
|
||||
* from values that already exist in original.
|
||||
* @template T
|
||||
* @param {Partial<T>} input New value.
|
||||
* @param {T} original Original value.
|
||||
* @returns {boolean} Whether input includes an explicit difference.
|
||||
*/
|
||||
function containsDifferentProperty(input, original) {
|
||||
if (input === original) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
typeof input !== typeof original ||
|
||||
Array.isArray(input) !== Array.isArray(original)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Array.isArray(input)) {
|
||||
return (
|
||||
input.length !== original.length ||
|
||||
input.some((value, i) =>
|
||||
containsDifferentProperty(value, original[i]),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof input === "object") {
|
||||
if (input === null || original === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const inputKeys = Object.keys(input);
|
||||
const originalKeys = Object.keys(original);
|
||||
|
||||
return (
|
||||
inputKeys.length !== originalKeys.length ||
|
||||
inputKeys.some(
|
||||
inputKey =>
|
||||
!Object.hasOwn(original, inputKey) ||
|
||||
containsDifferentProperty(
|
||||
input[inputKey],
|
||||
original[inputKey],
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
containsDifferentProperty,
|
||||
};
|
28
slider/node_modules/eslint/lib/shared/relative-module-resolver.js
generated
vendored
Normal file
28
slider/node_modules/eslint/lib/shared/relative-module-resolver.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Utility for resolving a module relative to another module
|
||||
* @author Teddy Katz
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Module = require("node:module");
|
||||
|
||||
/*
|
||||
* `Module.createRequire` is added in v12.2.0. It supports URL as well.
|
||||
* We only support the case where the argument is a filepath, not a URL.
|
||||
*/
|
||||
const createRequire = Module.createRequire;
|
||||
|
||||
/**
|
||||
* Resolves a Node module relative to another module
|
||||
* @param {string} moduleName The name of a Node module, or a path to a Node module.
|
||||
* @param {string} relativeToPath An absolute path indicating the module that `moduleName` should be resolved relative to. This must be
|
||||
* a file rather than a directory, but the file need not actually exist.
|
||||
* @returns {string} The absolute path that would result from calling `require.resolve(moduleName)` in a file located at `relativeToPath`
|
||||
* @throws {Error} When the module cannot be resolved.
|
||||
*/
|
||||
function resolve(moduleName, relativeToPath) {
|
||||
return createRequire(relativeToPath).resolve(moduleName);
|
||||
}
|
||||
|
||||
exports.resolve = resolve;
|
177
slider/node_modules/eslint/lib/shared/runtime-info.js
generated
vendored
Normal file
177
slider/node_modules/eslint/lib/shared/runtime-info.js
generated
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
/**
|
||||
* @fileoverview Utility to get information about the execution environment.
|
||||
* @author Kai Cataldo
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const path = require("node:path");
|
||||
const spawn = require("cross-spawn");
|
||||
const os = require("node:os");
|
||||
const log = require("../shared/logging");
|
||||
const packageJson = require("../../package.json");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Generates and returns execution environment information.
|
||||
* @returns {string} A string that contains execution environment information.
|
||||
*/
|
||||
function environment() {
|
||||
const cache = new Map();
|
||||
|
||||
/**
|
||||
* Checks if a path is a child of a directory.
|
||||
* @param {string} parentPath The parent path to check.
|
||||
* @param {string} childPath The path to check.
|
||||
* @returns {boolean} Whether or not the given path is a child of a directory.
|
||||
*/
|
||||
function isChildOfDirectory(parentPath, childPath) {
|
||||
return !path.relative(parentPath, childPath).startsWith("..");
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronously executes a shell command and formats the result.
|
||||
* @param {string} cmd The command to execute.
|
||||
* @param {Array} args The arguments to be executed with the command.
|
||||
* @throws {Error} As may be collected by `cross-spawn.sync`.
|
||||
* @returns {string} The version returned by the command.
|
||||
*/
|
||||
function execCommand(cmd, args) {
|
||||
const key = [cmd, ...args].join(" ");
|
||||
|
||||
if (cache.has(key)) {
|
||||
return cache.get(key);
|
||||
}
|
||||
|
||||
const process = spawn.sync(cmd, args, { encoding: "utf8" });
|
||||
|
||||
if (process.error) {
|
||||
throw process.error;
|
||||
}
|
||||
|
||||
const result = process.stdout.trim();
|
||||
|
||||
cache.set(key, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a version number.
|
||||
* @param {string} versionStr The string to normalize.
|
||||
* @returns {string} The normalized version number.
|
||||
*/
|
||||
function normalizeVersionStr(versionStr) {
|
||||
return versionStr.startsWith("v") ? versionStr : `v${versionStr}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets bin version.
|
||||
* @param {string} bin The bin to check.
|
||||
* @throws {Error} As may be collected by `cross-spawn.sync`.
|
||||
* @returns {string} The normalized version returned by the command.
|
||||
*/
|
||||
function getBinVersion(bin) {
|
||||
const binArgs = ["--version"];
|
||||
|
||||
try {
|
||||
return normalizeVersionStr(execCommand(bin, binArgs));
|
||||
} catch (e) {
|
||||
log.error(
|
||||
`Error finding ${bin} version running the command \`${bin} ${binArgs.join(" ")}\``,
|
||||
);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets installed npm package version.
|
||||
* @param {string} pkg The package to check.
|
||||
* @param {boolean} global Whether to check globally or not.
|
||||
* @throws {Error} As may be collected by `cross-spawn.sync`.
|
||||
* @returns {string} The normalized version returned by the command.
|
||||
*/
|
||||
function getNpmPackageVersion(pkg, { global = false } = {}) {
|
||||
const npmBinArgs = ["bin", "-g"];
|
||||
const npmLsArgs = ["ls", "--depth=0", "--json", pkg];
|
||||
|
||||
if (global) {
|
||||
npmLsArgs.push("-g");
|
||||
}
|
||||
|
||||
try {
|
||||
const parsedStdout = JSON.parse(execCommand("npm", npmLsArgs));
|
||||
|
||||
/*
|
||||
* Checking globally returns an empty JSON object, while local checks
|
||||
* include the name and version of the local project.
|
||||
*/
|
||||
if (
|
||||
Object.keys(parsedStdout).length === 0 ||
|
||||
!(parsedStdout.dependencies && parsedStdout.dependencies.eslint)
|
||||
) {
|
||||
return "Not found";
|
||||
}
|
||||
|
||||
const [, processBinPath] = process.argv;
|
||||
let npmBinPath;
|
||||
|
||||
try {
|
||||
npmBinPath = execCommand("npm", npmBinArgs);
|
||||
} catch (e) {
|
||||
log.error(
|
||||
`Error finding npm binary path when running command \`npm ${npmBinArgs.join(" ")}\``,
|
||||
);
|
||||
throw e;
|
||||
}
|
||||
|
||||
const isGlobal = isChildOfDirectory(npmBinPath, processBinPath);
|
||||
let pkgVersion = parsedStdout.dependencies.eslint.version;
|
||||
|
||||
if ((global && isGlobal) || (!global && !isGlobal)) {
|
||||
pkgVersion += " (Currently used)";
|
||||
}
|
||||
|
||||
return normalizeVersionStr(pkgVersion);
|
||||
} catch (e) {
|
||||
log.error(
|
||||
`Error finding ${pkg} version running the command \`npm ${npmLsArgs.join(" ")}\``,
|
||||
);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
"Environment Info:",
|
||||
"",
|
||||
`Node version: ${process.version}`,
|
||||
`npm version: ${getBinVersion("npm")}`,
|
||||
`Local ESLint version: ${getNpmPackageVersion("eslint", { global: false })}`,
|
||||
`Global ESLint version: ${getNpmPackageVersion("eslint", { global: true })}`,
|
||||
`Operating System: ${os.platform()} ${os.release()}`,
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns version of currently executing ESLint.
|
||||
* @returns {string} The version from the currently executing ESLint's package.json.
|
||||
*/
|
||||
function version() {
|
||||
return `v${packageJson.version}`;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
module.exports = {
|
||||
__esModule: true, // Indicate intent for imports, remove ambiguity for Knip (see: https://github.com/eslint/eslint/pull/18005#discussion_r1484422616)
|
||||
environment,
|
||||
version,
|
||||
};
|
78
slider/node_modules/eslint/lib/shared/serialization.js
generated
vendored
Normal file
78
slider/node_modules/eslint/lib/shared/serialization.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @fileoverview Serialization utils.
|
||||
* @author Bryan Mishkin
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Check if a value is a primitive or plain object created by the Object constructor.
|
||||
* @param {any} val the value to check
|
||||
* @returns {boolean} true if so
|
||||
* @private
|
||||
*/
|
||||
function isSerializablePrimitiveOrPlainObject(val) {
|
||||
return (
|
||||
val === null ||
|
||||
typeof val === "string" ||
|
||||
typeof val === "boolean" ||
|
||||
typeof val === "number" ||
|
||||
(typeof val === "object" && val.constructor === Object) ||
|
||||
Array.isArray(val)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a value is serializable.
|
||||
* Functions or objects like RegExp cannot be serialized by JSON.stringify().
|
||||
* Inspired by: https://stackoverflow.com/questions/30579940/reliable-way-to-check-if-objects-is-serializable-in-javascript
|
||||
* @param {any} val The value
|
||||
* @param {Set<Object>} seenObjects Objects already seen in this path from the root object.
|
||||
* @returns {boolean} `true` if the value is serializable
|
||||
*/
|
||||
function isSerializable(val, seenObjects = new Set()) {
|
||||
if (!isSerializablePrimitiveOrPlainObject(val)) {
|
||||
return false;
|
||||
}
|
||||
if (typeof val === "object" && val !== null) {
|
||||
if (seenObjects.has(val)) {
|
||||
/*
|
||||
* Since this is a depth-first traversal, encountering
|
||||
* the same object again means there is a circular reference.
|
||||
* Objects with circular references are not serializable.
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
for (const property in val) {
|
||||
if (Object.hasOwn(val, property)) {
|
||||
if (!isSerializablePrimitiveOrPlainObject(val[property])) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
typeof val[property] === "object" &&
|
||||
val[property] !== null
|
||||
) {
|
||||
if (
|
||||
/*
|
||||
* We're creating a new Set of seen objects because we want to
|
||||
* ensure that `val` doesn't appear again in this path, but it can appear
|
||||
* in other paths. This allows for resuing objects in the graph, as long as
|
||||
* there are no cycles.
|
||||
*/
|
||||
!isSerializable(
|
||||
val[property],
|
||||
new Set([...seenObjects, val]),
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isSerializable,
|
||||
};
|
49
slider/node_modules/eslint/lib/shared/severity.js
generated
vendored
Normal file
49
slider/node_modules/eslint/lib/shared/severity.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @fileoverview Helpers for severity values (e.g. normalizing different types).
|
||||
* @author Bryan Mishkin
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Convert severity value of different types to a string.
|
||||
* @param {string|number} severity severity value
|
||||
* @throws error if severity is invalid
|
||||
* @returns {string} severity string
|
||||
*/
|
||||
function normalizeSeverityToString(severity) {
|
||||
if ([2, "2", "error"].includes(severity)) {
|
||||
return "error";
|
||||
}
|
||||
if ([1, "1", "warn"].includes(severity)) {
|
||||
return "warn";
|
||||
}
|
||||
if ([0, "0", "off"].includes(severity)) {
|
||||
return "off";
|
||||
}
|
||||
throw new Error(`Invalid severity value: ${severity}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert severity value of different types to a number.
|
||||
* @param {string|number} severity severity value
|
||||
* @throws error if severity is invalid
|
||||
* @returns {number} severity number
|
||||
*/
|
||||
function normalizeSeverityToNumber(severity) {
|
||||
if ([2, "2", "error"].includes(severity)) {
|
||||
return 2;
|
||||
}
|
||||
if ([1, "1", "warn"].includes(severity)) {
|
||||
return 1;
|
||||
}
|
||||
if ([0, "0", "off"].includes(severity)) {
|
||||
return 0;
|
||||
}
|
||||
throw new Error(`Invalid severity value: ${severity}`);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
normalizeSeverityToString,
|
||||
normalizeSeverityToNumber,
|
||||
};
|
30
slider/node_modules/eslint/lib/shared/stats.js
generated
vendored
Normal file
30
slider/node_modules/eslint/lib/shared/stats.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @fileoverview Provides helper functions to start/stop the time measurements
|
||||
* that are provided by the ESLint 'stats' option.
|
||||
* @author Mara Kiefer <http://github.com/mnkiefer>
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Start time measurement
|
||||
* @returns {[number, number]} t variable for tracking time
|
||||
*/
|
||||
function startTime() {
|
||||
return process.hrtime();
|
||||
}
|
||||
|
||||
/**
|
||||
* End time measurement
|
||||
* @param {[number, number]} t Variable for tracking time
|
||||
* @returns {number} The measured time in milliseconds
|
||||
*/
|
||||
function endTime(t) {
|
||||
const time = process.hrtime(t);
|
||||
|
||||
return time[0] * 1e3 + time[1] / 1e6;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
startTime,
|
||||
endTime,
|
||||
};
|
58
slider/node_modules/eslint/lib/shared/string-utils.js
generated
vendored
Normal file
58
slider/node_modules/eslint/lib/shared/string-utils.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* @fileoverview Utilities to operate on strings.
|
||||
* @author Stephen Wade
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// eslint-disable-next-line no-control-regex -- intentionally including control characters
|
||||
const ASCII_REGEX = /^[\u0000-\u007f]*$/u;
|
||||
|
||||
/** @type {Intl.Segmenter | undefined} */
|
||||
let segmenter;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Converts the first letter of a string to uppercase.
|
||||
* @param {string} string The string to operate on
|
||||
* @returns {string} The converted string
|
||||
*/
|
||||
function upperCaseFirst(string) {
|
||||
if (string.length <= 1) {
|
||||
return string.toUpperCase();
|
||||
}
|
||||
return string[0].toUpperCase() + string.slice(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts graphemes in a given string.
|
||||
* @param {string} value A string to count graphemes.
|
||||
* @returns {number} The number of graphemes in `value`.
|
||||
*/
|
||||
function getGraphemeCount(value) {
|
||||
if (ASCII_REGEX.test(value)) {
|
||||
return value.length;
|
||||
}
|
||||
|
||||
segmenter ??= new Intl.Segmenter("en-US"); // en-US locale should be supported everywhere
|
||||
let graphemeCount = 0;
|
||||
|
||||
// eslint-disable-next-line no-unused-vars -- for-of needs a variable
|
||||
for (const unused of segmenter.segment(value)) {
|
||||
graphemeCount++;
|
||||
}
|
||||
|
||||
return graphemeCount;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
upperCaseFirst,
|
||||
getGraphemeCount,
|
||||
};
|
68
slider/node_modules/eslint/lib/shared/text-table.js
generated
vendored
Normal file
68
slider/node_modules/eslint/lib/shared/text-table.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @fileoverview Optimized version of the `text-table` npm module to improve performance by replacing inefficient regex-based
|
||||
* whitespace trimming with a modern built-in method.
|
||||
*
|
||||
* This modification addresses a performance issue reported in https://github.com/eslint/eslint/issues/18709
|
||||
*
|
||||
* The `text-table` module is published under the MIT License. For the original source, refer to:
|
||||
* https://www.npmjs.com/package/text-table.
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* This software is released under the MIT license:
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports = function (rows_, opts) {
|
||||
const hsep = " ";
|
||||
const align = opts.align;
|
||||
const stringLength = opts.stringLength;
|
||||
|
||||
const sizes = rows_.reduce((acc, row) => {
|
||||
row.forEach((c, ix) => {
|
||||
const n = stringLength(c);
|
||||
|
||||
if (!acc[ix] || n > acc[ix]) {
|
||||
acc[ix] = n;
|
||||
}
|
||||
});
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
return rows_
|
||||
.map(row =>
|
||||
row
|
||||
.map((c, ix) => {
|
||||
const n = sizes[ix] - stringLength(c) || 0;
|
||||
const s = Array(Math.max(n + 1, 1)).join(" ");
|
||||
|
||||
if (align[ix] === "r") {
|
||||
return s + c;
|
||||
}
|
||||
|
||||
return c + s;
|
||||
})
|
||||
.join(hsep)
|
||||
.trimEnd(),
|
||||
)
|
||||
.join("\n");
|
||||
};
|
281
slider/node_modules/eslint/lib/shared/translate-cli-options.js
generated
vendored
Normal file
281
slider/node_modules/eslint/lib/shared/translate-cli-options.js
generated
vendored
Normal file
@@ -0,0 +1,281 @@
|
||||
/**
|
||||
* @fileoverview Translates CLI options into ESLint constructor options.
|
||||
* @author Nicholas C. Zakas
|
||||
* @author Francesco Trotta
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const { normalizeSeverityToString } = require("./severity");
|
||||
const { getShorthandName, normalizePackageName } = require("./naming");
|
||||
const { ModuleImporter } = require("@humanwhocodes/module-importer");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Types
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("../types").ESLint.Options} ESLintOptions */
|
||||
/** @typedef {import("../types").ESLint.LegacyOptions} LegacyESLintOptions */
|
||||
/** @typedef {import("../types").Linter.LintMessage} LintMessage */
|
||||
/** @typedef {import("../options").ParsedCLIOptions} ParsedCLIOptions */
|
||||
/** @typedef {import("../types").ESLint.Plugin} Plugin */
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Loads plugins with the specified names.
|
||||
* @param {{ "import": (name: string) => Promise<any> }} importer An object with an `import` method called once for each plugin.
|
||||
* @param {string[]} pluginNames The names of the plugins to be loaded, with or without the "eslint-plugin-" prefix.
|
||||
* @returns {Promise<Record<string, Plugin>>} A mapping of plugin short names to implementations.
|
||||
*/
|
||||
async function loadPlugins(importer, pluginNames) {
|
||||
const plugins = {};
|
||||
|
||||
await Promise.all(
|
||||
pluginNames.map(async pluginName => {
|
||||
const longName = normalizePackageName(pluginName, "eslint-plugin");
|
||||
const module = await importer.import(longName);
|
||||
|
||||
if (!("default" in module)) {
|
||||
throw new Error(
|
||||
`"${longName}" cannot be used with the \`--plugin\` option because its default module does not provide a \`default\` export`,
|
||||
);
|
||||
}
|
||||
|
||||
const shortName = getShorthandName(pluginName, "eslint-plugin");
|
||||
|
||||
plugins[shortName] = module.default;
|
||||
}),
|
||||
);
|
||||
|
||||
return plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Predicate function for whether or not to apply fixes in quiet mode.
|
||||
* If a message is a warning, do not apply a fix.
|
||||
* @param {LintMessage} message The lint result.
|
||||
* @returns {boolean} True if the lint message is an error (and thus should be
|
||||
* autofixed), false otherwise.
|
||||
*/
|
||||
function quietFixPredicate(message) {
|
||||
return message.severity === 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Predicate function for whether or not to run a rule in quiet mode.
|
||||
* If a rule is set to warning, do not run it.
|
||||
* @param {{ ruleId: string; severity: number; }} rule The rule id and severity.
|
||||
* @returns {boolean} True if the lint rule should run, false otherwise.
|
||||
*/
|
||||
function quietRuleFilter(rule) {
|
||||
return rule.severity === 2;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Translates the CLI options into the options expected by the ESLint constructor.
|
||||
* @param {ParsedCLIOptions} cliOptions The CLI options to translate.
|
||||
* @param {"flat"|"eslintrc"} [configType="eslintrc"] The format of the config to generate.
|
||||
* @returns {Promise<ESLintOptions | LegacyESLintOptions>} The options object for the ESLint constructor.
|
||||
*/
|
||||
async function translateOptions(
|
||||
{
|
||||
cache,
|
||||
cacheFile,
|
||||
cacheLocation,
|
||||
cacheStrategy,
|
||||
concurrency,
|
||||
config,
|
||||
configLookup,
|
||||
env,
|
||||
errorOnUnmatchedPattern,
|
||||
eslintrc,
|
||||
ext,
|
||||
fix,
|
||||
fixDryRun,
|
||||
fixType,
|
||||
flag,
|
||||
global,
|
||||
ignore,
|
||||
ignorePath,
|
||||
ignorePattern,
|
||||
inlineConfig,
|
||||
parser,
|
||||
parserOptions,
|
||||
plugin,
|
||||
quiet,
|
||||
reportUnusedDisableDirectives,
|
||||
reportUnusedDisableDirectivesSeverity,
|
||||
reportUnusedInlineConfigs,
|
||||
resolvePluginsRelativeTo,
|
||||
rule,
|
||||
rulesdir,
|
||||
stats,
|
||||
warnIgnored,
|
||||
passOnNoPatterns,
|
||||
maxWarnings,
|
||||
},
|
||||
configType,
|
||||
) {
|
||||
let overrideConfig, overrideConfigFile;
|
||||
const importer = new ModuleImporter();
|
||||
|
||||
if (configType === "flat") {
|
||||
overrideConfigFile =
|
||||
typeof config === "string" ? config : !configLookup;
|
||||
if (overrideConfigFile === false) {
|
||||
overrideConfigFile = void 0;
|
||||
}
|
||||
|
||||
const languageOptions = {};
|
||||
|
||||
if (global) {
|
||||
languageOptions.globals = global.reduce((obj, name) => {
|
||||
if (name.endsWith(":true")) {
|
||||
obj[name.slice(0, -5)] = "writable";
|
||||
} else {
|
||||
obj[name] = "readonly";
|
||||
}
|
||||
return obj;
|
||||
}, {});
|
||||
}
|
||||
|
||||
if (parserOptions) {
|
||||
languageOptions.parserOptions = parserOptions;
|
||||
}
|
||||
|
||||
if (parser) {
|
||||
languageOptions.parser = await importer.import(parser);
|
||||
}
|
||||
|
||||
overrideConfig = [
|
||||
{
|
||||
...(Object.keys(languageOptions).length > 0
|
||||
? { languageOptions }
|
||||
: {}),
|
||||
rules: rule ? rule : {},
|
||||
},
|
||||
];
|
||||
|
||||
if (
|
||||
reportUnusedDisableDirectives ||
|
||||
reportUnusedDisableDirectivesSeverity !== void 0
|
||||
) {
|
||||
overrideConfig[0].linterOptions = {
|
||||
reportUnusedDisableDirectives: reportUnusedDisableDirectives
|
||||
? "error"
|
||||
: normalizeSeverityToString(
|
||||
reportUnusedDisableDirectivesSeverity,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (reportUnusedInlineConfigs !== void 0) {
|
||||
overrideConfig[0].linterOptions = {
|
||||
...overrideConfig[0].linterOptions,
|
||||
reportUnusedInlineConfigs: normalizeSeverityToString(
|
||||
reportUnusedInlineConfigs,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (plugin) {
|
||||
overrideConfig[0].plugins = await loadPlugins(importer, plugin);
|
||||
}
|
||||
|
||||
if (ext) {
|
||||
overrideConfig.push({
|
||||
files: ext.map(
|
||||
extension =>
|
||||
`**/*${extension.startsWith(".") ? "" : "."}${extension}`,
|
||||
),
|
||||
});
|
||||
}
|
||||
} else {
|
||||
overrideConfigFile = config;
|
||||
|
||||
overrideConfig = {
|
||||
env:
|
||||
env &&
|
||||
env.reduce((obj, name) => {
|
||||
obj[name] = true;
|
||||
return obj;
|
||||
}, {}),
|
||||
globals:
|
||||
global &&
|
||||
global.reduce((obj, name) => {
|
||||
if (name.endsWith(":true")) {
|
||||
obj[name.slice(0, -5)] = "writable";
|
||||
} else {
|
||||
obj[name] = "readonly";
|
||||
}
|
||||
return obj;
|
||||
}, {}),
|
||||
ignorePatterns: ignorePattern,
|
||||
parser,
|
||||
parserOptions,
|
||||
plugins: plugin,
|
||||
rules: rule,
|
||||
};
|
||||
}
|
||||
|
||||
const options = {
|
||||
allowInlineConfig: inlineConfig,
|
||||
cache,
|
||||
cacheLocation: cacheLocation || cacheFile,
|
||||
cacheStrategy,
|
||||
errorOnUnmatchedPattern,
|
||||
fix: (fix || fixDryRun) && (quiet ? quietFixPredicate : true),
|
||||
fixTypes: fixType,
|
||||
ignore,
|
||||
overrideConfig,
|
||||
overrideConfigFile,
|
||||
passOnNoPatterns,
|
||||
};
|
||||
|
||||
if (configType === "flat") {
|
||||
options.concurrency = concurrency;
|
||||
options.flags = flag;
|
||||
options.ignorePatterns = ignorePattern;
|
||||
options.stats = stats;
|
||||
options.warnIgnored = warnIgnored;
|
||||
|
||||
/*
|
||||
* For performance reasons rules not marked as 'error' are filtered out in quiet mode. As maxWarnings
|
||||
* requires rules set to 'warn' to be run, we only filter out 'warn' rules if maxWarnings is not specified.
|
||||
*/
|
||||
options.ruleFilter =
|
||||
quiet && maxWarnings === -1 ? quietRuleFilter : () => true;
|
||||
} else {
|
||||
options.resolvePluginsRelativeTo = resolvePluginsRelativeTo;
|
||||
options.rulePaths = rulesdir;
|
||||
options.useEslintrc = eslintrc;
|
||||
options.extensions = ext;
|
||||
options.ignorePath = ignorePath;
|
||||
if (
|
||||
reportUnusedDisableDirectives ||
|
||||
reportUnusedDisableDirectivesSeverity !== void 0
|
||||
) {
|
||||
options.reportUnusedDisableDirectives =
|
||||
reportUnusedDisableDirectives
|
||||
? "error"
|
||||
: normalizeSeverityToString(
|
||||
reportUnusedDisableDirectivesSeverity,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
module.exports = translateOptions;
|
202
slider/node_modules/eslint/lib/shared/traverser.js
generated
vendored
Normal file
202
slider/node_modules/eslint/lib/shared/traverser.js
generated
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
/**
|
||||
* @fileoverview Traverser to traverse AST trees.
|
||||
* @author Nicholas C. Zakas
|
||||
* @author Toru Nagashima
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const vk = require("eslint-visitor-keys");
|
||||
const debug = require("debug")("eslint:traverser");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Do nothing.
|
||||
* @returns {void}
|
||||
*/
|
||||
function noop() {
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the given value is an ASTNode or not.
|
||||
* @param {any} x The value to check.
|
||||
* @returns {boolean} `true` if the value is an ASTNode.
|
||||
*/
|
||||
function isNode(x) {
|
||||
return x !== null && typeof x === "object" && typeof x.type === "string";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the visitor keys of a given node.
|
||||
* @param {Object} visitorKeys The map of visitor keys.
|
||||
* @param {ASTNode} node The node to get their visitor keys.
|
||||
* @returns {string[]} The visitor keys of the node.
|
||||
*/
|
||||
function getVisitorKeys(visitorKeys, node) {
|
||||
let keys = visitorKeys[node.type];
|
||||
|
||||
if (!keys) {
|
||||
keys = vk.getKeys(node);
|
||||
debug(
|
||||
'Unknown node type "%s": Estimated visitor keys %j',
|
||||
node.type,
|
||||
keys,
|
||||
);
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* The traverser class to traverse AST trees.
|
||||
*/
|
||||
class Traverser {
|
||||
constructor() {
|
||||
this._current = null;
|
||||
this._parents = [];
|
||||
this._skipped = false;
|
||||
this._broken = false;
|
||||
this._visitorKeys = null;
|
||||
this._enter = null;
|
||||
this._leave = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives current node.
|
||||
* @returns {ASTNode} The current node.
|
||||
*/
|
||||
current() {
|
||||
return this._current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives a copy of the ancestor nodes.
|
||||
* @returns {ASTNode[]} The ancestor nodes.
|
||||
*/
|
||||
parents() {
|
||||
return this._parents.slice(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Break the current traversal.
|
||||
* @returns {void}
|
||||
*/
|
||||
break() {
|
||||
this._broken = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip child nodes for the current traversal.
|
||||
* @returns {void}
|
||||
*/
|
||||
skip() {
|
||||
this._skipped = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverse the given AST tree.
|
||||
* @param {ASTNode} node The root node to traverse.
|
||||
* @param {Object} options The option object.
|
||||
* @param {Object} [options.visitorKeys=DEFAULT_VISITOR_KEYS] The keys of each node types to traverse child nodes. Default is `./default-visitor-keys.json`.
|
||||
* @param {Function} [options.enter=noop] The callback function which is called on entering each node.
|
||||
* @param {Function} [options.leave=noop] The callback function which is called on leaving each node.
|
||||
* @returns {void}
|
||||
*/
|
||||
traverse(node, options) {
|
||||
this._current = null;
|
||||
this._parents = [];
|
||||
this._skipped = false;
|
||||
this._broken = false;
|
||||
this._visitorKeys = options.visitorKeys || vk.KEYS;
|
||||
this._enter = options.enter || noop;
|
||||
this._leave = options.leave || noop;
|
||||
this._traverse(node, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverse the given AST tree recursively.
|
||||
* @param {ASTNode} node The current node.
|
||||
* @param {ASTNode|null} parent The parent node.
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
_traverse(node, parent) {
|
||||
if (!isNode(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._current = node;
|
||||
this._skipped = false;
|
||||
this._enter(node, parent);
|
||||
|
||||
if (!this._skipped && !this._broken) {
|
||||
const keys = getVisitorKeys(this._visitorKeys, node);
|
||||
|
||||
if (keys.length >= 1) {
|
||||
this._parents.push(node);
|
||||
for (let i = 0; i < keys.length && !this._broken; ++i) {
|
||||
const child = node[keys[i]];
|
||||
|
||||
if (Array.isArray(child)) {
|
||||
for (
|
||||
let j = 0;
|
||||
j < child.length && !this._broken;
|
||||
++j
|
||||
) {
|
||||
this._traverse(child[j], node);
|
||||
}
|
||||
} else {
|
||||
this._traverse(child, node);
|
||||
}
|
||||
}
|
||||
this._parents.pop();
|
||||
}
|
||||
}
|
||||
|
||||
if (!this._broken) {
|
||||
this._leave(node, parent);
|
||||
}
|
||||
|
||||
this._current = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the keys to use for traversal.
|
||||
* @param {ASTNode} node The node to read keys from.
|
||||
* @returns {string[]} An array of keys to visit on the node.
|
||||
* @private
|
||||
*/
|
||||
static getKeys(node) {
|
||||
return vk.getKeys(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverse the given AST tree.
|
||||
* @param {ASTNode} node The root node to traverse.
|
||||
* @param {Object} options The option object.
|
||||
* @param {Object} [options.visitorKeys=DEFAULT_VISITOR_KEYS] The keys of each node types to traverse child nodes. Default is `./default-visitor-keys.json`.
|
||||
* @param {Function} [options.enter=noop] The callback function which is called on entering each node.
|
||||
* @param {Function} [options.leave=noop] The callback function which is called on leaving each node.
|
||||
* @returns {void}
|
||||
*/
|
||||
static traverse(node, options) {
|
||||
new Traverser().traverse(node, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* The default visitor keys.
|
||||
* @type {Object}
|
||||
*/
|
||||
static get DEFAULT_VISITOR_KEYS() {
|
||||
return vk.KEYS;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Traverser;
|
Reference in New Issue
Block a user