forked from public/fvtt-cthulhu-eternal
Initial import with skill sheet working
This commit is contained in:
34
node_modules/eslint/lib/shared/ajv.js
generated
vendored
Normal file
34
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;
|
||||
};
|
22
node_modules/eslint/lib/shared/assert.js
generated
vendored
Normal file
22
node_modules/eslint/lib/shared/assert.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @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;
|
29
node_modules/eslint/lib/shared/ast-utils.js
generated
vendored
Normal file
29
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
|
||||
};
|
60
node_modules/eslint/lib/shared/deep-merge-arrays.js
generated
vendored
Normal file
60
node_modules/eslint/lib/shared/deep-merge-arrays.js
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @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 };
|
15
node_modules/eslint/lib/shared/directives.js
generated
vendored
Normal file
15
node_modules/eslint/lib/shared/directives.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @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
|
||||
};
|
28
node_modules/eslint/lib/shared/flags.js
generated
vendored
Normal file
28
node_modules/eslint/lib/shared/flags.js
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @fileoverview Shared flags for ESLint.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* 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."],
|
||||
["unstable_config_lookup_from_file", "Look up eslint.config.js from the file being linted."],
|
||||
["unstable_ts_config", "Enable TypeScript configuration files."]
|
||||
]);
|
||||
|
||||
/**
|
||||
* The set of flags that used to be active but no longer have an effect.
|
||||
* @type {Map<string, string>}
|
||||
*/
|
||||
const inactiveFlags = new Map([
|
||||
["test_only_old", "Used only for testing."]
|
||||
]);
|
||||
|
||||
module.exports = {
|
||||
activeFlags,
|
||||
inactiveFlags
|
||||
};
|
39
node_modules/eslint/lib/shared/logging.js
generated
vendored
Normal file
39
node_modules/eslint/lib/shared/logging.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
};
|
168
node_modules/eslint/lib/shared/runtime-info.js
generated
vendored
Normal file
168
node_modules/eslint/lib/shared/runtime-info.js
generated
vendored
Normal file
@ -0,0 +1,168 @@
|
||||
/**
|
||||
* @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: ${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 = {
|
||||
__esModule: true, // Indicate intent for imports, remove ambiguity for Knip (see: https://github.com/eslint/eslint/pull/18005#discussion_r1484422616)
|
||||
environment,
|
||||
version
|
||||
};
|
55
node_modules/eslint/lib/shared/serialization.js
generated
vendored
Normal file
55
node_modules/eslint/lib/shared/serialization.js
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
* @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
|
||||
* @returns {boolean} true if the value is serializable
|
||||
*/
|
||||
function isSerializable(val) {
|
||||
if (!isSerializablePrimitiveOrPlainObject(val)) {
|
||||
return false;
|
||||
}
|
||||
if (typeof val === "object") {
|
||||
for (const property in val) {
|
||||
if (Object.hasOwn(val, property)) {
|
||||
if (!isSerializablePrimitiveOrPlainObject(val[property])) {
|
||||
return false;
|
||||
}
|
||||
if (typeof val[property] === "object") {
|
||||
if (!isSerializable(val[property])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isSerializable
|
||||
};
|
49
node_modules/eslint/lib/shared/severity.js
generated
vendored
Normal file
49
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
node_modules/eslint/lib/shared/stats.js
generated
vendored
Normal file
30
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
node_modules/eslint/lib/shared/string-utils.js
generated
vendored
Normal file
58
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
|
||||
};
|
67
node_modules/eslint/lib/shared/text-table.js
generated
vendored
Normal file
67
node_modules/eslint/lib/shared/text-table.js
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @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");
|
||||
};
|
195
node_modules/eslint/lib/shared/traverser.js
generated
vendored
Normal file
195
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
251
node_modules/eslint/lib/shared/types.js
generated
vendored
Normal file
251
node_modules/eslint/lib/shared/types.js
generated
vendored
Normal file
@ -0,0 +1,251 @@
|
||||
/**
|
||||
* @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|13|14|15|16|2015|2016|2017|2018|2019|2020|2021|2022|2023|2024|2025} [ecmaVersion] The ECMAScript version (or revision number).
|
||||
* @property {"script"|"module"} [sourceType] The source code type.
|
||||
* @property {boolean} [allowReserved] Allowing the use of reserved words as identifiers in ES3.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} LanguageOptions
|
||||
* @property {number|"latest"} [ecmaVersion] The ECMAScript version (or revision number).
|
||||
* @property {Record<string, GlobalConf>} [globals] The global variable settings.
|
||||
* @property {"script"|"module"|"commonjs"} [sourceType] The source code type.
|
||||
* @property {string|Object} [parser] The parser to use.
|
||||
* @property {Object} [parserOptions] The parser options to use.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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|undefined} 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|undefined} line The 1-based line number.
|
||||
* @property {string} message The error message.
|
||||
* @property {string} [messageId] The ID of the message in the rule's meta.
|
||||
* @property {(string|null)} nodeType Type of node
|
||||
* @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} SuppressedLintMessage
|
||||
* @property {number|undefined} 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|undefined} line The 1-based line number.
|
||||
* @property {string} message The error message.
|
||||
* @property {string} [messageId] The ID of the message in the rule's meta.
|
||||
* @property {(string|null)} nodeType Type of node
|
||||
* @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<{kind: string, justification: string}>} suppressions The suppression info.
|
||||
* @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} 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 {Array} [defaultOptions] Default options for the rule.
|
||||
* @property {RuleMetaDocs} docs The document information of the rule.
|
||||
* @property {"code"|"whitespace"} [fixable] The autofix type.
|
||||
* @property {boolean} [hasSuggestions] If `true` then the rule provides suggestions.
|
||||
* @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, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A linting result.
|
||||
* @typedef {Object} LintResult
|
||||
* @property {string} filePath The path to the file that was linted.
|
||||
* @property {LintMessage[]} messages All of the messages for the result.
|
||||
* @property {SuppressedLintMessage[]} suppressedMessages All of the suppressed messages for the result.
|
||||
* @property {number} errorCount Number of errors for the result.
|
||||
* @property {number} fatalErrorCount Number of fatal errors for the result.
|
||||
* @property {number} warningCount Number of warnings for the result.
|
||||
* @property {number} fixableErrorCount Number of fixable errors for the result.
|
||||
* @property {number} fixableWarningCount Number of fixable warnings for the result.
|
||||
* @property {Stats} [stats] The performance statistics collected with the `stats` flag.
|
||||
* @property {string} [source] The source code of the file that was linted.
|
||||
* @property {string} [output] The source code of the file that was linted, with as many fixes applied as possible.
|
||||
* @property {DeprecatedRuleInfo[]} usedDeprecatedRules The list of used deprecated rules.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Performance statistics
|
||||
* @typedef {Object} Stats
|
||||
* @property {number} fixPasses The number of times ESLint has applied at least one fix after linting.
|
||||
* @property {Times} times The times spent on (parsing, fixing, linting) a file.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Performance Times for each ESLint pass
|
||||
* @typedef {Object} Times
|
||||
* @property {TimePass[]} passes Time passes
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} TimePass
|
||||
* @property {ParseTime} parse The parse object containing all parse time information.
|
||||
* @property {Record<string, RuleTime>} [rules] The rules object containing all lint time information for each rule.
|
||||
* @property {FixTime} fix The parse object containing all fix time information.
|
||||
* @property {number} total The total time that is spent on (parsing, fixing, linting) a file.
|
||||
*/
|
||||
/**
|
||||
* @typedef {Object} ParseTime
|
||||
* @property {number} total The total time that is spent when parsing a file.
|
||||
*/
|
||||
/**
|
||||
* @typedef {Object} RuleTime
|
||||
* @property {number} total The total time that is spent on a rule.
|
||||
*/
|
||||
/**
|
||||
* @typedef {Object} FixTime
|
||||
* @property {number} total The total time that is spent on applying fixes to the code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Information provided when the maximum warning threshold is exceeded.
|
||||
* @typedef {Object} MaxWarningsExceeded
|
||||
* @property {number} maxWarnings Number of warnings to trigger nonzero exit code.
|
||||
* @property {number} foundWarnings Number of warnings found while linting.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Metadata about results for formatters.
|
||||
* @typedef {Object} ResultsMeta
|
||||
* @property {MaxWarningsExceeded} [maxWarningsExceeded] Present if the maxWarnings threshold was exceeded.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A formatter function.
|
||||
* @callback FormatterFunction
|
||||
* @param {LintResult[]} results The list of linting results.
|
||||
* @param {{cwd: string, maxWarningsExceeded?: MaxWarningsExceeded, rulesMeta: Record<string, RuleMeta>}} context A context object.
|
||||
* @returns {string | Promise<string>} Formatted text.
|
||||
*/
|
Reference in New Issue
Block a user