first commit
This commit is contained in:
34
app_vue/node_modules/eslint/lib/shared/ajv.js
generated
vendored
Normal file
34
app_vue/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._opts.defaultMeta = metaSchema.id;
|
||||
|
||||
return ajv;
|
||||
};
|
29
app_vue/node_modules/eslint/lib/shared/ast-utils.js
generated
vendored
Normal file
29
app_vue/node_modules/eslint/lib/shared/ast-utils.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @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
|
||||
};
|
338
app_vue/node_modules/eslint/lib/shared/config-validator.js
generated
vendored
Normal file
338
app_vue/node_modules/eslint/lib/shared/config-validator.js
generated
vendored
Normal file
@ -0,0 +1,338 @@
|
||||
/*
|
||||
* STOP!!! DO NOT MODIFY.
|
||||
*
|
||||
* This file is part of the ongoing work to move the eslintrc-style config
|
||||
* system into the @eslint/eslintrc package. This file needs to remain
|
||||
* unchanged in order for this work to proceed.
|
||||
*
|
||||
* If you think you need to change this file, please contact @nzakas first.
|
||||
*
|
||||
* Thanks in advance for your cooperation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Validates configs.
|
||||
* @author Brandon Mills
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const
|
||||
util = require("util"),
|
||||
configSchema = require("../../conf/config-schema"),
|
||||
BuiltInEnvironments = require("@eslint/eslintrc/conf/environments"),
|
||||
BuiltInRules = require("../rules"),
|
||||
ConfigOps = require("@eslint/eslintrc/lib/shared/config-ops"),
|
||||
{ emitDeprecationWarning } = require("./deprecation-warnings");
|
||||
|
||||
const ajv = require("./ajv")();
|
||||
const ruleValidators = new WeakMap();
|
||||
const noop = Function.prototype;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Private
|
||||
//------------------------------------------------------------------------------
|
||||
let validateSchema;
|
||||
const severityMap = {
|
||||
error: 2,
|
||||
warn: 1,
|
||||
off: 0
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets a complete options schema for a rule.
|
||||
* @param {{create: Function, schema: (Array|null)}} rule A new-style rule object
|
||||
* @returns {Object} JSON Schema for the rule's options.
|
||||
*/
|
||||
function getRuleOptionsSchema(rule) {
|
||||
if (!rule) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const schema = rule.schema || rule.meta && rule.meta.schema;
|
||||
|
||||
// Given a tuple of schemas, insert warning level at the beginning
|
||||
if (Array.isArray(schema)) {
|
||||
if (schema.length) {
|
||||
return {
|
||||
type: "array",
|
||||
items: schema,
|
||||
minItems: 0,
|
||||
maxItems: schema.length
|
||||
};
|
||||
}
|
||||
return {
|
||||
type: "array",
|
||||
minItems: 0,
|
||||
maxItems: 0
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// Given a full schema, leave it alone
|
||||
return schema || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid.
|
||||
* @param {options} options The given options for the rule.
|
||||
* @returns {number|string} The rule's severity value
|
||||
*/
|
||||
function validateRuleSeverity(options) {
|
||||
const severity = Array.isArray(options) ? options[0] : options;
|
||||
const normSeverity = typeof severity === "string" ? severityMap[severity.toLowerCase()] : severity;
|
||||
|
||||
if (normSeverity === 0 || normSeverity === 1 || normSeverity === 2) {
|
||||
return normSeverity;
|
||||
}
|
||||
|
||||
throw new Error(`\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '${util.inspect(severity).replace(/'/gu, "\"").replace(/\n/gu, "")}').\n`);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the non-severity options passed to a rule, based on its schema.
|
||||
* @param {{create: Function}} rule The rule to validate
|
||||
* @param {Array} localOptions The options for the rule, excluding severity
|
||||
* @returns {void}
|
||||
*/
|
||||
function validateRuleSchema(rule, localOptions) {
|
||||
if (!ruleValidators.has(rule)) {
|
||||
const schema = getRuleOptionsSchema(rule);
|
||||
|
||||
if (schema) {
|
||||
ruleValidators.set(rule, ajv.compile(schema));
|
||||
}
|
||||
}
|
||||
|
||||
const validateRule = ruleValidators.get(rule);
|
||||
|
||||
if (validateRule) {
|
||||
validateRule(localOptions);
|
||||
if (validateRule.errors) {
|
||||
throw new Error(validateRule.errors.map(
|
||||
error => `\tValue ${JSON.stringify(error.data)} ${error.message}.\n`
|
||||
).join(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a rule's options against its schema.
|
||||
* @param {{create: Function}|null} rule The rule that the config is being validated for
|
||||
* @param {string} ruleId The rule's unique name.
|
||||
* @param {Array|number} options The given options for the rule.
|
||||
* @param {string|null} source The name of the configuration source to report in any errors. If null or undefined,
|
||||
* no source is prepended to the message.
|
||||
* @returns {void}
|
||||
*/
|
||||
function validateRuleOptions(rule, ruleId, options, source = null) {
|
||||
try {
|
||||
const severity = validateRuleSeverity(options);
|
||||
|
||||
if (severity !== 0) {
|
||||
validateRuleSchema(rule, Array.isArray(options) ? options.slice(1) : []);
|
||||
}
|
||||
} catch (err) {
|
||||
const enhancedMessage = `Configuration for rule "${ruleId}" is invalid:\n${err.message}`;
|
||||
|
||||
if (typeof source === "string") {
|
||||
throw new Error(`${source}:\n\t${enhancedMessage}`);
|
||||
} else {
|
||||
throw new Error(enhancedMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates an environment object
|
||||
* @param {Object} environment The environment config object to validate.
|
||||
* @param {string} source The name of the configuration source to report in any errors.
|
||||
* @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded environments.
|
||||
* @returns {void}
|
||||
*/
|
||||
function validateEnvironment(
|
||||
environment,
|
||||
source,
|
||||
getAdditionalEnv = noop
|
||||
) {
|
||||
|
||||
// not having an environment is ok
|
||||
if (!environment) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object.keys(environment).forEach(id => {
|
||||
const env = getAdditionalEnv(id) || BuiltInEnvironments.get(id) || null;
|
||||
|
||||
if (!env) {
|
||||
const message = `${source}:\n\tEnvironment key "${id}" is unknown\n`;
|
||||
|
||||
throw new Error(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a rules config object
|
||||
* @param {Object} rulesConfig The rules config object to validate.
|
||||
* @param {string} source The name of the configuration source to report in any errors.
|
||||
* @param {function(ruleId:string): Object} getAdditionalRule A map from strings to loaded rules
|
||||
* @returns {void}
|
||||
*/
|
||||
function validateRules(
|
||||
rulesConfig,
|
||||
source,
|
||||
getAdditionalRule = noop
|
||||
) {
|
||||
if (!rulesConfig) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object.keys(rulesConfig).forEach(id => {
|
||||
const rule = getAdditionalRule(id) || BuiltInRules.get(id) || null;
|
||||
|
||||
validateRuleOptions(rule, id, rulesConfig[id], source);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a `globals` section of a config file
|
||||
* @param {Object} globalsConfig The `globals` section
|
||||
* @param {string|null} source The name of the configuration source to report in the event of an error.
|
||||
* @returns {void}
|
||||
*/
|
||||
function validateGlobals(globalsConfig, source = null) {
|
||||
if (!globalsConfig) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object.entries(globalsConfig)
|
||||
.forEach(([configuredGlobal, configuredValue]) => {
|
||||
try {
|
||||
ConfigOps.normalizeConfigGlobal(configuredValue);
|
||||
} catch (err) {
|
||||
throw new Error(`ESLint configuration of global '${configuredGlobal}' in ${source} is invalid:\n${err.message}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate `processor` configuration.
|
||||
* @param {string|undefined} processorName The processor name.
|
||||
* @param {string} source The name of config file.
|
||||
* @param {function(id:string): Processor} getProcessor The getter of defined processors.
|
||||
* @returns {void}
|
||||
*/
|
||||
function validateProcessor(processorName, source, getProcessor) {
|
||||
if (processorName && !getProcessor(processorName)) {
|
||||
throw new Error(`ESLint configuration of processor in '${source}' is invalid: '${processorName}' was not found.`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats an array of schema validation errors.
|
||||
* @param {Array} errors An array of error messages to format.
|
||||
* @returns {string} Formatted error message
|
||||
*/
|
||||
function formatErrors(errors) {
|
||||
return errors.map(error => {
|
||||
if (error.keyword === "additionalProperties") {
|
||||
const formattedPropertyPath = error.dataPath.length ? `${error.dataPath.slice(1)}.${error.params.additionalProperty}` : error.params.additionalProperty;
|
||||
|
||||
return `Unexpected top-level property "${formattedPropertyPath}"`;
|
||||
}
|
||||
if (error.keyword === "type") {
|
||||
const formattedField = error.dataPath.slice(1);
|
||||
const formattedExpectedType = Array.isArray(error.schema) ? error.schema.join("/") : error.schema;
|
||||
const formattedValue = JSON.stringify(error.data);
|
||||
|
||||
return `Property "${formattedField}" is the wrong type (expected ${formattedExpectedType} but got \`${formattedValue}\`)`;
|
||||
}
|
||||
|
||||
const field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath;
|
||||
|
||||
return `"${field}" ${error.message}. Value: ${JSON.stringify(error.data)}`;
|
||||
}).map(message => `\t- ${message}.\n`).join("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the top level properties of the config object.
|
||||
* @param {Object} config The config object to validate.
|
||||
* @param {string} source The name of the configuration source to report in any errors.
|
||||
* @returns {void}
|
||||
*/
|
||||
function validateConfigSchema(config, source = null) {
|
||||
validateSchema = validateSchema || ajv.compile(configSchema);
|
||||
|
||||
if (!validateSchema(config)) {
|
||||
throw new Error(`ESLint configuration in ${source} is invalid:\n${formatErrors(validateSchema.errors)}`);
|
||||
}
|
||||
|
||||
if (Object.hasOwnProperty.call(config, "ecmaFeatures")) {
|
||||
emitDeprecationWarning(source, "ESLINT_LEGACY_ECMAFEATURES");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates an entire config object.
|
||||
* @param {Object} config The config object to validate.
|
||||
* @param {string} source The name of the configuration source to report in any errors.
|
||||
* @param {function(ruleId:string): Object} [getAdditionalRule] A map from strings to loaded rules.
|
||||
* @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded envs.
|
||||
* @returns {void}
|
||||
*/
|
||||
function validate(config, source, getAdditionalRule, getAdditionalEnv) {
|
||||
validateConfigSchema(config, source);
|
||||
validateRules(config.rules, source, getAdditionalRule);
|
||||
validateEnvironment(config.env, source, getAdditionalEnv);
|
||||
validateGlobals(config.globals, source);
|
||||
|
||||
for (const override of config.overrides || []) {
|
||||
validateRules(override.rules, source, getAdditionalRule);
|
||||
validateEnvironment(override.env, source, getAdditionalEnv);
|
||||
validateGlobals(config.globals, source);
|
||||
}
|
||||
}
|
||||
|
||||
const validated = new WeakSet();
|
||||
|
||||
/**
|
||||
* Validate config array object.
|
||||
* @param {ConfigArray} configArray The config array to validate.
|
||||
* @returns {void}
|
||||
*/
|
||||
function validateConfigArray(configArray) {
|
||||
const getPluginEnv = Map.prototype.get.bind(configArray.pluginEnvironments);
|
||||
const getPluginProcessor = Map.prototype.get.bind(configArray.pluginProcessors);
|
||||
const getPluginRule = Map.prototype.get.bind(configArray.pluginRules);
|
||||
|
||||
// Validate.
|
||||
for (const element of configArray) {
|
||||
if (validated.has(element)) {
|
||||
continue;
|
||||
}
|
||||
validated.add(element);
|
||||
|
||||
validateEnvironment(element.env, element.name, getPluginEnv);
|
||||
validateGlobals(element.globals, element.name);
|
||||
validateProcessor(element.processor, element.name, getPluginProcessor);
|
||||
validateRules(element.rules, element.name, getPluginRule);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
module.exports = {
|
||||
getRuleOptionsSchema,
|
||||
validate,
|
||||
validateConfigArray,
|
||||
validateConfigSchema,
|
||||
validateRuleOptions
|
||||
};
|
65
app_vue/node_modules/eslint/lib/shared/deprecation-warnings.js
generated
vendored
Normal file
65
app_vue/node_modules/eslint/lib/shared/deprecation-warnings.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @fileoverview Provide the function that emits deprecation warnings.
|
||||
* @author Toru Nagashima <http://github.com/mysticatea>
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const path = require("path");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Private
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Definitions for deprecation warnings.
|
||||
const deprecationWarningMessages = {
|
||||
ESLINT_LEGACY_ECMAFEATURES:
|
||||
"The 'ecmaFeatures' config file property is deprecated and has no effect.",
|
||||
ESLINT_PERSONAL_CONFIG_LOAD:
|
||||
"'~/.eslintrc.*' config files have been deprecated. " +
|
||||
"Please use a config file per project or the '--config' option.",
|
||||
ESLINT_PERSONAL_CONFIG_SUPPRESS:
|
||||
"'~/.eslintrc.*' config files have been deprecated. " +
|
||||
"Please remove it or add 'root:true' to the config files in your " +
|
||||
"projects in order to avoid loading '~/.eslintrc.*' accidentally."
|
||||
};
|
||||
|
||||
const sourceFileErrorCache = new Set();
|
||||
|
||||
/**
|
||||
* Emits a deprecation warning containing a given filepath. A new deprecation warning is emitted
|
||||
* for each unique file path, but repeated invocations with the same file path have no effect.
|
||||
* No warnings are emitted if the `--no-deprecation` or `--no-warnings` Node runtime flags are active.
|
||||
* @param {string} source The name of the configuration source to report the warning for.
|
||||
* @param {string} errorCode The warning message to show.
|
||||
* @returns {void}
|
||||
*/
|
||||
function emitDeprecationWarning(source, errorCode) {
|
||||
const cacheKey = JSON.stringify({ source, errorCode });
|
||||
|
||||
if (sourceFileErrorCache.has(cacheKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
sourceFileErrorCache.add(cacheKey);
|
||||
|
||||
const rel = path.relative(process.cwd(), source);
|
||||
const message = deprecationWarningMessages[errorCode];
|
||||
|
||||
process.emitWarning(
|
||||
`${message} (found in "${rel}")`,
|
||||
"DeprecationWarning",
|
||||
errorCode
|
||||
);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
module.exports = {
|
||||
emitDeprecationWarning
|
||||
};
|
30
app_vue/node_modules/eslint/lib/shared/logging.js
generated
vendored
Normal file
30
app_vue/node_modules/eslint/lib/shared/logging.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @fileoverview Handle logging for ESLint
|
||||
* @author Gyandeep Singh
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/* eslint no-console: "off" */
|
||||
|
||||
/* istanbul ignore next */
|
||||
module.exports = {
|
||||
|
||||
/**
|
||||
* Cover for console.log
|
||||
* @param {...any} args The elements to log.
|
||||
* @returns {void}
|
||||
*/
|
||||
info(...args) {
|
||||
console.log(...args);
|
||||
},
|
||||
|
||||
/**
|
||||
* Cover for console.error
|
||||
* @param {...any} args The elements to log.
|
||||
* @returns {void}
|
||||
*/
|
||||
error(...args) {
|
||||
console.error(...args);
|
||||
}
|
||||
};
|
56
app_vue/node_modules/eslint/lib/shared/relative-module-resolver.js
generated
vendored
Normal file
56
app_vue/node_modules/eslint/lib/shared/relative-module-resolver.js
generated
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* STOP!!! DO NOT MODIFY.
|
||||
*
|
||||
* This file is part of the ongoing work to move the eslintrc-style config
|
||||
* system into the @eslint/eslintrc package. This file needs to remain
|
||||
* unchanged in order for this work to proceed.
|
||||
*
|
||||
* If you think you need to change this file, please contact @nzakas first.
|
||||
*
|
||||
* Thanks in advance for your cooperation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Utility for resolving a module relative to another module
|
||||
* @author Teddy Katz
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Module = require("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.
|
||||
*/
|
||||
// eslint-disable-next-line node/no-unsupported-features/node-builtins, node/no-deprecated-api
|
||||
const createRequire = Module.createRequire || Module.createRequireFromPath;
|
||||
|
||||
module.exports = {
|
||||
|
||||
/**
|
||||
* 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`
|
||||
*/
|
||||
resolve(moduleName, relativeToPath) {
|
||||
try {
|
||||
return createRequire(relativeToPath).resolve(moduleName);
|
||||
} catch (error) {
|
||||
|
||||
// This `if` block is for older Node.js than 12.0.0. We can remove this block in the future.
|
||||
if (
|
||||
typeof error === "object" &&
|
||||
error !== null &&
|
||||
error.code === "MODULE_NOT_FOUND" &&
|
||||
!error.requireStack &&
|
||||
error.message.includes(moduleName)
|
||||
) {
|
||||
error.message += `\nRequire stack:\n- ${relativeToPath}`;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
164
app_vue/node_modules/eslint/lib/shared/runtime-info.js
generated
vendored
Normal file
164
app_vue/node_modules/eslint/lib/shared/runtime-info.js
generated
vendored
Normal file
@ -0,0 +1,164 @@
|
||||
/**
|
||||
* @fileoverview Utility to get information about the execution environment.
|
||||
* @author Kai Cataldo
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const path = require("path");
|
||||
const spawn = require("cross-spawn");
|
||||
const os = require("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.
|
||||
* @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.
|
||||
* @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.
|
||||
* @returns {string} The normalized version returned by the command.
|
||||
*/
|
||||
function getNpmPackageVersion(pkg, { global = false } = {}) {
|
||||
const npmBinArgs = ["bin", "-g"];
|
||||
const npmLsArgs = ["ls", "--depth=0", "--json", "eslint"];
|
||||
|
||||
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: ${getBinVersion("node")}`,
|
||||
`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 = {
|
||||
environment,
|
||||
version
|
||||
};
|
22
app_vue/node_modules/eslint/lib/shared/string-utils.js
generated
vendored
Normal file
22
app_vue/node_modules/eslint/lib/shared/string-utils.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @fileoverview Utilities to operate on strings.
|
||||
* @author Stephen Wade
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
upperCaseFirst
|
||||
};
|
195
app_vue/node_modules/eslint/lib/shared/traverser.js
generated
vendored
Normal file
195
app_vue/node_modules/eslint/lib/shared/traverser.js
generated
vendored
Normal file
@ -0,0 +1,195 @@
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* @returns {ASTNode} The current node.
|
||||
*/
|
||||
current() {
|
||||
return this._current;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* @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;
|
150
app_vue/node_modules/eslint/lib/shared/types.js
generated
vendored
Normal file
150
app_vue/node_modules/eslint/lib/shared/types.js
generated
vendored
Normal file
@ -0,0 +1,150 @@
|
||||
/**
|
||||
* @fileoverview Define common types for input completion.
|
||||
* @author Toru Nagashima <https://github.com/mysticatea>
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
/** @type {any} */
|
||||
module.exports = {};
|
||||
|
||||
/** @typedef {boolean | "off" | "readable" | "readonly" | "writable" | "writeable"} GlobalConf */
|
||||
/** @typedef {0 | 1 | 2 | "off" | "warn" | "error"} SeverityConf */
|
||||
/** @typedef {SeverityConf | [SeverityConf, ...any[]]} RuleConf */
|
||||
|
||||
/**
|
||||
* @typedef {Object} EcmaFeatures
|
||||
* @property {boolean} [globalReturn] Enabling `return` statements at the top-level.
|
||||
* @property {boolean} [jsx] Enabling JSX syntax.
|
||||
* @property {boolean} [impliedStrict] Enabling strict mode always.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ParserOptions
|
||||
* @property {EcmaFeatures} [ecmaFeatures] The optional features.
|
||||
* @property {3|5|6|7|8|9|10|11|12|2015|2016|2017|2018|2019|2020|2021} [ecmaVersion] The ECMAScript version (or revision number).
|
||||
* @property {"script"|"module"} [sourceType] The source code type.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ConfigData
|
||||
* @property {Record<string, boolean>} [env] The environment settings.
|
||||
* @property {string | string[]} [extends] The path to other config files or the package name of shareable configs.
|
||||
* @property {Record<string, GlobalConf>} [globals] The global variable settings.
|
||||
* @property {string | string[]} [ignorePatterns] The glob patterns that ignore to lint.
|
||||
* @property {boolean} [noInlineConfig] The flag that disables directive comments.
|
||||
* @property {OverrideConfigData[]} [overrides] The override settings per kind of files.
|
||||
* @property {string} [parser] The path to a parser or the package name of a parser.
|
||||
* @property {ParserOptions} [parserOptions] The parser options.
|
||||
* @property {string[]} [plugins] The plugin specifiers.
|
||||
* @property {string} [processor] The processor specifier.
|
||||
* @property {boolean} [reportUnusedDisableDirectives] The flag to report unused `eslint-disable` comments.
|
||||
* @property {boolean} [root] The root flag.
|
||||
* @property {Record<string, RuleConf>} [rules] The rule settings.
|
||||
* @property {Object} [settings] The shared settings.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} OverrideConfigData
|
||||
* @property {Record<string, boolean>} [env] The environment settings.
|
||||
* @property {string | string[]} [excludedFiles] The glob patterns for excluded files.
|
||||
* @property {string | string[]} [extends] The path to other config files or the package name of shareable configs.
|
||||
* @property {string | string[]} files The glob patterns for target files.
|
||||
* @property {Record<string, GlobalConf>} [globals] The global variable settings.
|
||||
* @property {boolean} [noInlineConfig] The flag that disables directive comments.
|
||||
* @property {OverrideConfigData[]} [overrides] The override settings per kind of files.
|
||||
* @property {string} [parser] The path to a parser or the package name of a parser.
|
||||
* @property {ParserOptions} [parserOptions] The parser options.
|
||||
* @property {string[]} [plugins] The plugin specifiers.
|
||||
* @property {string} [processor] The processor specifier.
|
||||
* @property {boolean} [reportUnusedDisableDirectives] The flag to report unused `eslint-disable` comments.
|
||||
* @property {Record<string, RuleConf>} [rules] The rule settings.
|
||||
* @property {Object} [settings] The shared settings.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ParseResult
|
||||
* @property {Object} ast The AST.
|
||||
* @property {ScopeManager} [scopeManager] The scope manager of the AST.
|
||||
* @property {Record<string, any>} [services] The services that the parser provides.
|
||||
* @property {Record<string, string[]>} [visitorKeys] The visitor keys of the AST.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} Parser
|
||||
* @property {(text:string, options:ParserOptions) => Object} parse The definition of global variables.
|
||||
* @property {(text:string, options:ParserOptions) => ParseResult} [parseForESLint] The parser options that will be enabled under this environment.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} Environment
|
||||
* @property {Record<string, GlobalConf>} [globals] The definition of global variables.
|
||||
* @property {ParserOptions} [parserOptions] The parser options that will be enabled under this environment.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} LintMessage
|
||||
* @property {number} column The 1-based column number.
|
||||
* @property {number} [endColumn] The 1-based column number of the end location.
|
||||
* @property {number} [endLine] The 1-based line number of the end location.
|
||||
* @property {boolean} fatal If `true` then this is a fatal error.
|
||||
* @property {{range:[number,number], text:string}} [fix] Information for autofix.
|
||||
* @property {number} line The 1-based line number.
|
||||
* @property {string} message The error message.
|
||||
* @property {string|null} ruleId The ID of the rule which makes this message.
|
||||
* @property {0|1|2} severity The severity of this message.
|
||||
* @property {Array<{desc?: string, messageId?: string, fix: {range: [number, number], text: string}}>} [suggestions] Information for suggestions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} SuggestionResult
|
||||
* @property {string} desc A short description.
|
||||
* @property {string} [messageId] Id referencing a message for the description.
|
||||
* @property {{ text: string, range: number[] }} fix fix result info
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} Processor
|
||||
* @property {(text:string, filename:string) => Array<string | { text:string, filename:string }>} [preprocess] The function to extract code blocks.
|
||||
* @property {(messagesList:LintMessage[][], filename:string) => LintMessage[]} [postprocess] The function to merge messages.
|
||||
* @property {boolean} [supportsAutofix] If `true` then it means the processor supports autofix.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} RuleMetaDocs
|
||||
* @property {string} category The category of the rule.
|
||||
* @property {string} description The description of the rule.
|
||||
* @property {boolean} recommended If `true` then the rule is included in `eslint:recommended` preset.
|
||||
* @property {string} url The URL of the rule documentation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} RuleMeta
|
||||
* @property {boolean} [deprecated] If `true` then the rule has been deprecated.
|
||||
* @property {RuleMetaDocs} docs The document information of the rule.
|
||||
* @property {"code"|"whitespace"} [fixable] The autofix type.
|
||||
* @property {Record<string,string>} [messages] The messages the rule reports.
|
||||
* @property {string[]} [replacedBy] The IDs of the alternative rules.
|
||||
* @property {Array|Object} schema The option schema of the rule.
|
||||
* @property {"problem"|"suggestion"|"layout"} type The rule type.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} Rule
|
||||
* @property {Function} create The factory of the rule.
|
||||
* @property {RuleMeta} meta The meta data of the rule.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} Plugin
|
||||
* @property {Record<string, ConfigData>} [configs] The definition of plugin configs.
|
||||
* @property {Record<string, Environment>} [environments] The definition of plugin environments.
|
||||
* @property {Record<string, Processor>} [processors] The definition of plugin processors.
|
||||
* @property {Record<string, Function | Rule>} [rules] The definition of plugin rules.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Information of deprecated rules.
|
||||
* @typedef {Object} DeprecatedRuleInfo
|
||||
* @property {string} ruleId The rule ID.
|
||||
* @property {string[]} replacedBy The rule IDs that replace this deprecated rule.
|
||||
*/
|
Reference in New Issue
Block a user