mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
tools: update eslint to 8.26.0
PR-URL: https://github.com/nodejs/node/pull/45243 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
This commit is contained in:
1 parent
a8e901555a
commit
4b71db13ae
805 files changed
+4219
-12734
No files matched your search
+29
-8
@@ -143,12 +143,6 @@ async function translateOptions({
|
||||
overrideConfig[0].plugins = plugins;
|
||||
}
|
||||
|
||||
if (ignorePattern) {
|
||||
overrideConfig.push({
|
||||
ignores: ignorePattern
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
overrideConfigFile = config;
|
||||
|
||||
@@ -187,7 +181,9 @@ async function translateOptions({
|
||||
reportUnusedDisableDirectives: reportUnusedDisableDirectives ? "error" : void 0
|
||||
};
|
||||
|
||||
if (configType !== "flat") {
|
||||
if (configType === "flat") {
|
||||
options.ignorePatterns = ignorePattern;
|
||||
} else {
|
||||
options.resolvePluginsRelativeTo = resolvePluginsRelativeTo;
|
||||
options.rulePaths = rulesdir;
|
||||
options.useEslintrc = eslintrc;
|
||||
@@ -279,6 +275,31 @@ async function printResults(engine, results, format, outputFile, resultsMeta) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether flat config should be used.
|
||||
* @param {boolean} [allowFlatConfig] Whether or not to allow flat config.
|
||||
* @returns {Promise<boolean>} Where flat config should be used.
|
||||
*/
|
||||
async function shouldUseFlatConfig(allowFlatConfig) {
|
||||
if (!allowFlatConfig) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (process.env.ESLINT_USE_FLAT_CONFIG) {
|
||||
case "true":
|
||||
return true;
|
||||
case "false":
|
||||
return false;
|
||||
default:
|
||||
|
||||
/*
|
||||
* If neither explicitly enabled nor disabled, then use the presence
|
||||
* of a flat config file to determine enablement.
|
||||
*/
|
||||
return !!(await findFlatConfigFile(process.cwd()));
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -308,7 +329,7 @@ const cli = {
|
||||
* switch to flat config we can remove this logic.
|
||||
*/
|
||||
|
||||
const usingFlatConfig = allowFlatConfig && !!(await findFlatConfigFile(process.cwd()));
|
||||
const usingFlatConfig = await shouldUseFlatConfig(allowFlatConfig);
|
||||
|
||||
debug("Using flat config?", usingFlatConfig);
|
||||
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ exports.defaultConfig = [
|
||||
{
|
||||
ignores: [
|
||||
"**/node_modules/**",
|
||||
".git/**"
|
||||
".git/"
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
+199
-83
@@ -13,9 +13,19 @@ const path = require("path");
|
||||
const fs = require("fs");
|
||||
const fsp = fs.promises;
|
||||
const isGlob = require("is-glob");
|
||||
const globby = require("globby");
|
||||
const hash = require("../cli-engine/hash");
|
||||
const minimatch = require("minimatch");
|
||||
const util = require("util");
|
||||
const fswalk = require("@nodelib/fs.walk");
|
||||
const globParent = require("glob-parent");
|
||||
const isPathInside = require("is-path-inside");
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Fixup references
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const doFsWalk = util.promisify(fswalk.walk);
|
||||
const Minimatch = minimatch.Minimatch;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Errors
|
||||
@@ -97,6 +107,141 @@ function isGlobPattern(pattern) {
|
||||
return isGlob(path.sep === "\\" ? normalizeToPosix(pattern) : pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches a directory looking for matching glob patterns. This uses
|
||||
* the config array's logic to determine if a directory or file should
|
||||
* be ignored, so it is consistent with how ignoring works throughout
|
||||
* ESLint.
|
||||
* @param {Object} options The options for this function.
|
||||
* @param {string} options.basePath The directory to search.
|
||||
* @param {Array<string>} options.patterns An array of glob patterns
|
||||
* to match.
|
||||
* @param {FlatConfigArray} options.configs The config array to use for
|
||||
* determining what to ignore.
|
||||
* @returns {Promise<Array<string>>} An array of matching file paths
|
||||
* or an empty array if there are no matches.
|
||||
*/
|
||||
async function globSearch({ basePath, patterns, configs }) {
|
||||
|
||||
if (patterns.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const matchers = patterns.map(pattern => {
|
||||
const patternToUse = path.isAbsolute(pattern)
|
||||
? normalizeToPosix(path.relative(basePath, pattern))
|
||||
: pattern;
|
||||
|
||||
return new minimatch.Minimatch(patternToUse);
|
||||
});
|
||||
|
||||
return (await doFsWalk(basePath, {
|
||||
|
||||
deepFilter(entry) {
|
||||
const relativePath = normalizeToPosix(path.relative(basePath, entry.path));
|
||||
const matchesPattern = matchers.some(matcher => matcher.match(relativePath, true));
|
||||
|
||||
return matchesPattern && !configs.isDirectoryIgnored(entry.path);
|
||||
},
|
||||
entryFilter(entry) {
|
||||
const relativePath = normalizeToPosix(path.relative(basePath, entry.path));
|
||||
|
||||
// entries may be directories or files so filter out directories
|
||||
if (entry.dirent.isDirectory()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const matchesPattern = matchers.some(matcher => matcher.match(relativePath));
|
||||
|
||||
return matchesPattern && !configs.isFileIgnored(entry.path);
|
||||
}
|
||||
})).map(entry => entry.path);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs multiple glob searches in parallel.
|
||||
* @param {Object} options The options for this function.
|
||||
* @param {Array<{patterns:Array<string>,rawPatterns:Array<string>}>} options.searches
|
||||
* An array of glob patterns to match.
|
||||
* @param {FlatConfigArray} options.configs The config array to use for
|
||||
* determining what to ignore.
|
||||
* @returns {Promise<Array<string>>} An array of matching file paths
|
||||
* or an empty array if there are no matches.
|
||||
*/
|
||||
async function globMultiSearch({ searches, configs }) {
|
||||
|
||||
const results = await Promise.all(
|
||||
[...searches].map(
|
||||
([basePath, { patterns }]) => globSearch({ basePath, patterns, configs })
|
||||
)
|
||||
);
|
||||
|
||||
return [...new Set(results.flat())];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a given glob pattern will return any results.
|
||||
* Used primarily to help with useful error messages.
|
||||
* @param {Object} options The options for the function.
|
||||
* @param {string} options.basePath The directory to search.
|
||||
* @param {string} options.pattern A glob pattern to match.
|
||||
* @returns {Promise<boolean>} True if there is a glob match, false if not.
|
||||
*/
|
||||
function globMatch({ basePath, pattern }) {
|
||||
|
||||
let found = false;
|
||||
const patternToUse = path.isAbsolute(pattern)
|
||||
? normalizeToPosix(path.relative(basePath, pattern))
|
||||
: pattern;
|
||||
|
||||
const matcher = new Minimatch(patternToUse);
|
||||
|
||||
const fsWalkSettings = {
|
||||
|
||||
deepFilter(entry) {
|
||||
const relativePath = normalizeToPosix(path.relative(basePath, entry.path));
|
||||
|
||||
return !found && matcher.match(relativePath, true);
|
||||
},
|
||||
|
||||
entryFilter(entry) {
|
||||
if (found || entry.dirent.isDirectory()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const relativePath = normalizeToPosix(path.relative(basePath, entry.path));
|
||||
|
||||
if (matcher.match(relativePath)) {
|
||||
found = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
return new Promise(resolve => {
|
||||
|
||||
// using a stream so we can exit early because we just need one match
|
||||
const globStream = fswalk.walkStream(basePath, fsWalkSettings);
|
||||
|
||||
globStream.on("data", () => {
|
||||
globStream.destroy();
|
||||
resolve(true);
|
||||
});
|
||||
|
||||
// swallow errors as they're not important here
|
||||
globStream.on("error", () => {});
|
||||
|
||||
globStream.on("end", () => {
|
||||
resolve(false);
|
||||
});
|
||||
globStream.read();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all files matching the options specified.
|
||||
* @param {Object} args The arguments objects.
|
||||
@@ -120,8 +265,10 @@ async function findFiles({
|
||||
}) {
|
||||
|
||||
const results = [];
|
||||
const globbyPatterns = [];
|
||||
const missingPatterns = [];
|
||||
let globbyPatterns = [];
|
||||
let rawPatterns = [];
|
||||
const searches = new Map([[cwd, { patterns: globbyPatterns, rawPatterns: [] }]]);
|
||||
|
||||
// check to see if we have explicit files and directories
|
||||
const filePaths = patterns.map(filePath => path.resolve(cwd, filePath));
|
||||
@@ -142,76 +289,25 @@ async function findFiles({
|
||||
if (stat.isFile()) {
|
||||
results.push({
|
||||
filePath,
|
||||
ignored: configs.isIgnored(filePath)
|
||||
ignored: configs.isFileIgnored(filePath)
|
||||
});
|
||||
}
|
||||
|
||||
// directories need extensions attached
|
||||
if (stat.isDirectory()) {
|
||||
|
||||
// filePatterns are all relative to cwd
|
||||
const filePatterns = configs.files
|
||||
.filter(filePattern => {
|
||||
|
||||
// can only do this for strings, not functions
|
||||
if (typeof filePattern !== "string") {
|
||||
return false;
|
||||
}
|
||||
|
||||
// patterns starting with ** always apply
|
||||
if (filePattern.startsWith("**")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// patterns ending with * are not used for file search
|
||||
if (filePattern.endsWith("*")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// not sure how to handle negated patterns yet
|
||||
if (filePattern.startsWith("!")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if the pattern would be inside the config base path or not
|
||||
const fullFilePattern = path.join(cwd, filePattern);
|
||||
const patternRelativeToConfigBasePath = path.relative(configs.basePath, fullFilePattern);
|
||||
|
||||
if (patternRelativeToConfigBasePath.startsWith("..")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if the pattern matches
|
||||
if (minimatch(filePath, path.dirname(fullFilePattern), { partial: true })) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// check if the pattern is inside the directory or not
|
||||
const patternRelativeToFilePath = path.relative(filePath, fullFilePattern);
|
||||
|
||||
if (patternRelativeToFilePath.startsWith("..")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.map(filePattern => {
|
||||
if (filePattern.startsWith("**")) {
|
||||
return path.join(pattern, filePattern);
|
||||
}
|
||||
|
||||
// adjust the path to be relative to the cwd
|
||||
return path.relative(
|
||||
cwd,
|
||||
path.join(configs.basePath, filePattern)
|
||||
);
|
||||
})
|
||||
.map(normalizeToPosix);
|
||||
|
||||
if (filePatterns.length) {
|
||||
globbyPatterns.push(...filePatterns);
|
||||
// group everything in cwd together and split out others
|
||||
if (isPathInside(filePath, cwd)) {
|
||||
({ patterns: globbyPatterns, rawPatterns } = searches.get(cwd));
|
||||
} else {
|
||||
if (!searches.has(filePath)) {
|
||||
searches.set(filePath, { patterns: [], rawPatterns: [] });
|
||||
}
|
||||
({ patterns: globbyPatterns, rawPatterns } = searches.get(filePath));
|
||||
}
|
||||
|
||||
globbyPatterns.push(`${normalizeToPosix(filePath)}/**`);
|
||||
rawPatterns.push(pattern);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -219,39 +315,59 @@ async function findFiles({
|
||||
|
||||
// save patterns for later use based on whether globs are enabled
|
||||
if (globInputPaths && isGlobPattern(filePath)) {
|
||||
globbyPatterns.push(pattern);
|
||||
|
||||
const basePath = globParent(filePath);
|
||||
|
||||
// group in cwd if possible and split out others
|
||||
if (isPathInside(basePath, cwd)) {
|
||||
({ patterns: globbyPatterns, rawPatterns } = searches.get(cwd));
|
||||
} else {
|
||||
if (!searches.has(basePath)) {
|
||||
searches.set(basePath, { patterns: [], rawPatterns: [] });
|
||||
}
|
||||
({ patterns: globbyPatterns, rawPatterns } = searches.get(basePath));
|
||||
}
|
||||
|
||||
globbyPatterns.push(filePath);
|
||||
rawPatterns.push(pattern);
|
||||
} else {
|
||||
missingPatterns.push(pattern);
|
||||
}
|
||||
});
|
||||
|
||||
// note: globbyPatterns can be an empty array
|
||||
const globbyResults = (await globby(globbyPatterns, {
|
||||
cwd,
|
||||
absolute: true,
|
||||
ignore: configs.ignores.filter(matcher => typeof matcher === "string")
|
||||
}));
|
||||
const globbyResults = await globMultiSearch({
|
||||
searches,
|
||||
configs
|
||||
});
|
||||
|
||||
// if there are no results, tell the user why
|
||||
if (!results.length && !globbyResults.length) {
|
||||
|
||||
// try globby without ignoring anything
|
||||
/* eslint-disable no-unreachable-loop -- We want to exit early. */
|
||||
for (const globbyPattern of globbyPatterns) {
|
||||
for (const [basePath, { patterns: patternsToCheck, rawPatterns: patternsToReport }] of searches) {
|
||||
|
||||
/* eslint-disable-next-line no-unused-vars -- Want to exit early. */
|
||||
for await (const filePath of globby.stream(globbyPattern, { cwd, absolute: true })) {
|
||||
let index = 0;
|
||||
|
||||
// files were found but ignored
|
||||
throw new AllFilesIgnoredError(globbyPattern);
|
||||
}
|
||||
// try globby without ignoring anything
|
||||
for (const patternToCheck of patternsToCheck) {
|
||||
|
||||
// no files were found
|
||||
if (errorOnUnmatchedPattern) {
|
||||
throw new NoFilesFoundError(globbyPattern, globInputPaths);
|
||||
// check if there are any matches at all
|
||||
const patternHasMatch = await globMatch({
|
||||
basePath,
|
||||
pattern: patternToCheck
|
||||
});
|
||||
|
||||
if (patternHasMatch) {
|
||||
throw new AllFilesIgnoredError(patternsToReport[index]);
|
||||
}
|
||||
|
||||
// otherwise no files were found
|
||||
if (errorOnUnmatchedPattern) {
|
||||
throw new NoFilesFoundError(patternsToReport[index], globInputPaths);
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
/* eslint-enable no-unreachable-loop -- Go back to normal. */
|
||||
|
||||
}
|
||||
|
||||
|
||||
+20
-33
@@ -262,24 +262,16 @@ function findFlatConfigFile(cwd) {
|
||||
/**
|
||||
* Load the config array from the given filename.
|
||||
* @param {string} filePath The filename to load from.
|
||||
* @param {Object} options Options to help load the config file.
|
||||
* @param {string} options.basePath The base path for the config array.
|
||||
* @param {boolean} options.shouldIgnore Whether to honor ignore patterns.
|
||||
* @returns {Promise<FlatConfigArray>} The config array loaded from the config file.
|
||||
* @returns {Promise<any>} The config loaded from the config file.
|
||||
*/
|
||||
async function loadFlatConfigFile(filePath, { basePath, shouldIgnore }) {
|
||||
async function loadFlatConfigFile(filePath) {
|
||||
debug(`Loading config from ${filePath}`);
|
||||
|
||||
const fileURL = pathToFileURL(filePath);
|
||||
|
||||
debug(`Config file URL is ${fileURL}`);
|
||||
|
||||
const module = await import(fileURL);
|
||||
|
||||
return new FlatConfigArray(module.default, {
|
||||
basePath,
|
||||
shouldIgnore
|
||||
});
|
||||
return (await import(fileURL)).default;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,6 +282,7 @@ async function loadFlatConfigFile(filePath, { basePath, shouldIgnore }) {
|
||||
*/
|
||||
async function calculateConfigArray(eslint, {
|
||||
cwd,
|
||||
baseConfig,
|
||||
overrideConfig,
|
||||
configFile,
|
||||
ignore: shouldIgnore,
|
||||
@@ -321,16 +314,18 @@ async function calculateConfigArray(eslint, {
|
||||
basePath = path.resolve(path.dirname(configFilePath));
|
||||
}
|
||||
|
||||
// load config array
|
||||
let configs;
|
||||
|
||||
const configs = new FlatConfigArray(baseConfig || [], { basePath, shouldIgnore });
|
||||
|
||||
// load config file
|
||||
if (configFilePath) {
|
||||
configs = await loadFlatConfigFile(configFilePath, {
|
||||
basePath,
|
||||
shouldIgnore
|
||||
});
|
||||
} else {
|
||||
configs = new FlatConfigArray([], { basePath, shouldIgnore });
|
||||
const fileConfig = await loadFlatConfigFile(configFilePath);
|
||||
|
||||
if (Array.isArray(fileConfig)) {
|
||||
configs.push(...fileConfig);
|
||||
} else {
|
||||
configs.push(fileConfig);
|
||||
}
|
||||
}
|
||||
|
||||
// add in any configured defaults
|
||||
@@ -362,17 +357,6 @@ async function calculateConfigArray(eslint, {
|
||||
const negated = pattern.startsWith("!");
|
||||
const basePattern = negated ? pattern.slice(1) : pattern;
|
||||
|
||||
/*
|
||||
* Ignore patterns are considered relative to a directory
|
||||
* when the pattern contains a slash in a position other
|
||||
* than the last character. If that's the case, we need to
|
||||
* add the relative ignore path to the current pattern to
|
||||
* get the correct behavior. Otherwise, no change is needed.
|
||||
*/
|
||||
if (!basePattern.includes("/") || basePattern.endsWith("/")) {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
return (negated ? "!" : "") +
|
||||
path.posix.join(relativeIgnorePath, basePattern);
|
||||
});
|
||||
@@ -665,13 +649,12 @@ class FlatESLint {
|
||||
*/
|
||||
getRulesMetaForResults(results) {
|
||||
|
||||
const resultRules = new Map();
|
||||
|
||||
// short-circuit simple case
|
||||
if (results.length === 0) {
|
||||
return resultRules;
|
||||
return {};
|
||||
}
|
||||
|
||||
const resultRules = new Map();
|
||||
const { configs } = privateMembers.get(this);
|
||||
|
||||
/*
|
||||
@@ -700,6 +683,10 @@ class FlatESLint {
|
||||
const allMessages = result.messages.concat(result.suppressedMessages);
|
||||
|
||||
for (const { ruleId } of allMessages) {
|
||||
if (!ruleId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const rule = getRuleFromConfig(ruleId, config);
|
||||
|
||||
// ensure the rule exists
|
||||
|
||||
+1
@@ -213,6 +213,7 @@ function addDeclaredGlobals(globalScope, configGlobals, { exportedVariables, ena
|
||||
|
||||
if (variable) {
|
||||
variable.eslintUsed = true;
|
||||
variable.eslintExported = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+14
-8
@@ -112,18 +112,24 @@ module.exports = {
|
||||
}
|
||||
if (parent.type === "Property" && astUtils.getStaticPropertyName(parent) === "get" && parent.parent.type === "ObjectExpression") {
|
||||
|
||||
// Object.defineProperty()
|
||||
if (parent.parent.parent.type === "CallExpression" &&
|
||||
astUtils.getStaticPropertyName(parent.parent.parent.callee) === "defineProperty") {
|
||||
return true;
|
||||
// Object.defineProperty() or Reflect.defineProperty()
|
||||
if (parent.parent.parent.type === "CallExpression") {
|
||||
const callNode = parent.parent.parent.callee;
|
||||
|
||||
if (astUtils.isSpecificMemberAccess(callNode, "Object", "defineProperty") ||
|
||||
astUtils.isSpecificMemberAccess(callNode, "Reflect", "defineProperty")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Object.defineProperties()
|
||||
// Object.defineProperties() or Object.create()
|
||||
if (parent.parent.parent.type === "Property" &&
|
||||
parent.parent.parent.parent.type === "ObjectExpression" &&
|
||||
parent.parent.parent.parent.parent.type === "CallExpression" &&
|
||||
astUtils.getStaticPropertyName(parent.parent.parent.parent.parent.callee) === "defineProperties") {
|
||||
return true;
|
||||
parent.parent.parent.parent.parent.type === "CallExpression") {
|
||||
const callNode = parent.parent.parent.parent.parent.callee;
|
||||
|
||||
return astUtils.isSpecificMemberAccess(callNode, "Object", "defineProperties") ||
|
||||
astUtils.isSpecificMemberAccess(callNode, "Object", "create");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -77,6 +77,11 @@ module.exports = {
|
||||
return;
|
||||
}
|
||||
|
||||
// Variables exported by "exported" block comments
|
||||
if (variable.eslintExported) {
|
||||
return;
|
||||
}
|
||||
|
||||
variable.defs.forEach(def => {
|
||||
const defNode = def.node;
|
||||
|
||||
|
||||
Generated
Vendored
+146
File diff suppressed because it is too large.
Load diff
Generated
Vendored
+3
@@ -16,6 +16,9 @@
|
||||
"transform-template-literals": [
|
||||
"bugfix/transform-tagged-template-caching"
|
||||
],
|
||||
"transform-optional-chaining": [
|
||||
"bugfix/transform-v8-spread-parameters-in-optional-chaining"
|
||||
],
|
||||
"proposal-optional-chaining": [
|
||||
"bugfix/transform-v8-spread-parameters-in-optional-chaining"
|
||||
]
|
||||
|
||||
Generated
Vendored
+26
@@ -6,6 +6,7 @@
|
||||
"firefox": "52",
|
||||
"safari": "11",
|
||||
"node": "7.6",
|
||||
"deno": "1",
|
||||
"ios": "11",
|
||||
"samsung": "6",
|
||||
"electron": "1.6"
|
||||
@@ -17,6 +18,7 @@
|
||||
"firefox": "52",
|
||||
"safari": "10",
|
||||
"node": "6",
|
||||
"deno": "1",
|
||||
"ios": "10",
|
||||
"samsung": "5",
|
||||
"electron": "0.37"
|
||||
@@ -28,6 +30,7 @@
|
||||
"firefox": "53",
|
||||
"safari": "10",
|
||||
"node": "6.5",
|
||||
"deno": "1",
|
||||
"ios": "10",
|
||||
"samsung": "5",
|
||||
"electron": "1.2"
|
||||
@@ -39,6 +42,7 @@
|
||||
"firefox": "44",
|
||||
"safari": "11",
|
||||
"node": "6",
|
||||
"deno": "1",
|
||||
"ie": "11",
|
||||
"ios": "11",
|
||||
"samsung": "5",
|
||||
@@ -51,6 +55,7 @@
|
||||
"firefox": "4",
|
||||
"safari": "11",
|
||||
"node": "6",
|
||||
"deno": "1",
|
||||
"ie": "11",
|
||||
"ios": "11",
|
||||
"samsung": "5",
|
||||
@@ -63,6 +68,7 @@
|
||||
"edge": "14",
|
||||
"firefox": "2",
|
||||
"node": "6",
|
||||
"deno": "1",
|
||||
"samsung": "5",
|
||||
"electron": "0.37"
|
||||
},
|
||||
@@ -73,6 +79,7 @@
|
||||
"firefox": "34",
|
||||
"safari": "13",
|
||||
"node": "4",
|
||||
"deno": "1",
|
||||
"ios": "13",
|
||||
"samsung": "3.4",
|
||||
"rhino": "1.7.14",
|
||||
@@ -85,9 +92,22 @@
|
||||
"firefox": "74",
|
||||
"safari": "13.1",
|
||||
"node": "16.9",
|
||||
"deno": "1.9",
|
||||
"ios": "13.4",
|
||||
"electron": "13.0"
|
||||
},
|
||||
"transform-optional-chaining": {
|
||||
"chrome": "80",
|
||||
"opera": "67",
|
||||
"edge": "80",
|
||||
"firefox": "74",
|
||||
"safari": "13.1",
|
||||
"node": "14",
|
||||
"deno": "1",
|
||||
"ios": "13.4",
|
||||
"samsung": "13",
|
||||
"electron": "8.0"
|
||||
},
|
||||
"proposal-optional-chaining": {
|
||||
"chrome": "80",
|
||||
"opera": "67",
|
||||
@@ -95,6 +115,7 @@
|
||||
"firefox": "74",
|
||||
"safari": "13.1",
|
||||
"node": "14",
|
||||
"deno": "1",
|
||||
"ios": "13.4",
|
||||
"samsung": "13",
|
||||
"electron": "8.0"
|
||||
@@ -106,6 +127,7 @@
|
||||
"firefox": "53",
|
||||
"safari": "10",
|
||||
"node": "6",
|
||||
"deno": "1",
|
||||
"ios": "10",
|
||||
"samsung": "5",
|
||||
"electron": "0.37"
|
||||
@@ -117,6 +139,7 @@
|
||||
"firefox": "52",
|
||||
"safari": "10.1",
|
||||
"node": "7.6",
|
||||
"deno": "1",
|
||||
"ios": "10.3",
|
||||
"samsung": "6",
|
||||
"electron": "1.6"
|
||||
@@ -128,6 +151,7 @@
|
||||
"firefox": "34",
|
||||
"safari": "9",
|
||||
"node": "4",
|
||||
"deno": "1",
|
||||
"ios": "9",
|
||||
"samsung": "3.4",
|
||||
"electron": "0.21"
|
||||
@@ -139,6 +163,7 @@
|
||||
"firefox": "53",
|
||||
"safari": "10",
|
||||
"node": "6.5",
|
||||
"deno": "1",
|
||||
"ios": "10",
|
||||
"samsung": "5",
|
||||
"electron": "1.2"
|
||||
@@ -150,6 +175,7 @@
|
||||
"firefox": "51",
|
||||
"safari": "10",
|
||||
"node": "6",
|
||||
"deno": "1",
|
||||
"ios": "10",
|
||||
"samsung": "5",
|
||||
"electron": "0.37"
|
||||
|
||||
+207
@@ -1,12 +1,33 @@
|
||||
{
|
||||
"transform-class-static-block": {
|
||||
"chrome": "94",
|
||||
"opera": "80",
|
||||
"edge": "94",
|
||||
"firefox": "93",
|
||||
"node": "16.11",
|
||||
"deno": "1.14",
|
||||
"electron": "15.0"
|
||||
},
|
||||
"proposal-class-static-block": {
|
||||
"chrome": "94",
|
||||
"opera": "80",
|
||||
"edge": "94",
|
||||
"firefox": "93",
|
||||
"node": "16.11",
|
||||
"deno": "1.14",
|
||||
"electron": "15.0"
|
||||
},
|
||||
"transform-private-property-in-object": {
|
||||
"chrome": "91",
|
||||
"opera": "77",
|
||||
"edge": "91",
|
||||
"firefox": "90",
|
||||
"safari": "15",
|
||||
"node": "16.9",
|
||||
"deno": "1.9",
|
||||
"ios": "15",
|
||||
"electron": "13.0"
|
||||
},
|
||||
"proposal-private-property-in-object": {
|
||||
"chrome": "91",
|
||||
"opera": "77",
|
||||
@@ -14,9 +35,22 @@
|
||||
"firefox": "90",
|
||||
"safari": "15",
|
||||
"node": "16.9",
|
||||
"deno": "1.9",
|
||||
"ios": "15",
|
||||
"electron": "13.0"
|
||||
},
|
||||
"transform-class-properties": {
|
||||
"chrome": "74",
|
||||
"opera": "62",
|
||||
"edge": "79",
|
||||
"firefox": "90",
|
||||
"safari": "14.1",
|
||||
"node": "12",
|
||||
"deno": "1",
|
||||
"ios": "15",
|
||||
"samsung": "11",
|
||||
"electron": "6.0"
|
||||
},
|
||||
"proposal-class-properties": {
|
||||
"chrome": "74",
|
||||
"opera": "62",
|
||||
@@ -24,10 +58,23 @@
|
||||
"firefox": "90",
|
||||
"safari": "14.1",
|
||||
"node": "12",
|
||||
"deno": "1",
|
||||
"ios": "15",
|
||||
"samsung": "11",
|
||||
"electron": "6.0"
|
||||
},
|
||||
"transform-private-methods": {
|
||||
"chrome": "84",
|
||||
"opera": "70",
|
||||
"edge": "84",
|
||||
"firefox": "90",
|
||||
"safari": "15",
|
||||
"node": "14.6",
|
||||
"deno": "1",
|
||||
"ios": "15",
|
||||
"samsung": "14",
|
||||
"electron": "10.0"
|
||||
},
|
||||
"proposal-private-methods": {
|
||||
"chrome": "84",
|
||||
"opera": "70",
|
||||
@@ -35,10 +82,24 @@
|
||||
"firefox": "90",
|
||||
"safari": "15",
|
||||
"node": "14.6",
|
||||
"deno": "1",
|
||||
"ios": "15",
|
||||
"samsung": "14",
|
||||
"electron": "10.0"
|
||||
},
|
||||
"transform-numeric-separator": {
|
||||
"chrome": "75",
|
||||
"opera": "62",
|
||||
"edge": "79",
|
||||
"firefox": "70",
|
||||
"safari": "13",
|
||||
"node": "12.5",
|
||||
"deno": "1",
|
||||
"ios": "13",
|
||||
"samsung": "11",
|
||||
"rhino": "1.7.14",
|
||||
"electron": "6.0"
|
||||
},
|
||||
"proposal-numeric-separator": {
|
||||
"chrome": "75",
|
||||
"opera": "62",
|
||||
@@ -46,11 +107,24 @@
|
||||
"firefox": "70",
|
||||
"safari": "13",
|
||||
"node": "12.5",
|
||||
"deno": "1",
|
||||
"ios": "13",
|
||||
"samsung": "11",
|
||||
"rhino": "1.7.14",
|
||||
"electron": "6.0"
|
||||
},
|
||||
"transform-logical-assignment-operators": {
|
||||
"chrome": "85",
|
||||
"opera": "71",
|
||||
"edge": "85",
|
||||
"firefox": "79",
|
||||
"safari": "14",
|
||||
"node": "15",
|
||||
"deno": "1.2",
|
||||
"ios": "14",
|
||||
"samsung": "14",
|
||||
"electron": "10.0"
|
||||
},
|
||||
"proposal-logical-assignment-operators": {
|
||||
"chrome": "85",
|
||||
"opera": "71",
|
||||
@@ -58,10 +132,23 @@
|
||||
"firefox": "79",
|
||||
"safari": "14",
|
||||
"node": "15",
|
||||
"deno": "1.2",
|
||||
"ios": "14",
|
||||
"samsung": "14",
|
||||
"electron": "10.0"
|
||||
},
|
||||
"transform-nullish-coalescing-operator": {
|
||||
"chrome": "80",
|
||||
"opera": "67",
|
||||
"edge": "80",
|
||||
"firefox": "72",
|
||||
"safari": "13.1",
|
||||
"node": "14",
|
||||
"deno": "1",
|
||||
"ios": "13.4",
|
||||
"samsung": "13",
|
||||
"electron": "8.0"
|
||||
},
|
||||
"proposal-nullish-coalescing-operator": {
|
||||
"chrome": "80",
|
||||
"opera": "67",
|
||||
@@ -69,10 +156,22 @@
|
||||
"firefox": "72",
|
||||
"safari": "13.1",
|
||||
"node": "14",
|
||||
"deno": "1",
|
||||
"ios": "13.4",
|
||||
"samsung": "13",
|
||||
"electron": "8.0"
|
||||
},
|
||||
"transform-optional-chaining": {
|
||||
"chrome": "91",
|
||||
"opera": "77",
|
||||
"edge": "91",
|
||||
"firefox": "74",
|
||||
"safari": "13.1",
|
||||
"node": "16.9",
|
||||
"deno": "1.9",
|
||||
"ios": "13.4",
|
||||
"electron": "13.0"
|
||||
},
|
||||
"proposal-optional-chaining": {
|
||||
"chrome": "91",
|
||||
"opera": "77",
|
||||
@@ -80,9 +179,23 @@
|
||||
"firefox": "74",
|
||||
"safari": "13.1",
|
||||
"node": "16.9",
|
||||
"deno": "1.9",
|
||||
"ios": "13.4",
|
||||
"electron": "13.0"
|
||||
},
|
||||
"transform-json-strings": {
|
||||
"chrome": "66",
|
||||
"opera": "53",
|
||||
"edge": "79",
|
||||
"firefox": "62",
|
||||
"safari": "12",
|
||||
"node": "10",
|
||||
"deno": "1",
|
||||
"ios": "12",
|
||||
"samsung": "9",
|
||||
"rhino": "1.7.14",
|
||||
"electron": "3.0"
|
||||
},
|
||||
"proposal-json-strings": {
|
||||
"chrome": "66",
|
||||
"opera": "53",
|
||||
@@ -90,11 +203,24 @@
|
||||
"firefox": "62",
|
||||
"safari": "12",
|
||||
"node": "10",
|
||||
"deno": "1",
|
||||
"ios": "12",
|
||||
"samsung": "9",
|
||||
"rhino": "1.7.14",
|
||||
"electron": "3.0"
|
||||
},
|
||||
"transform-optional-catch-binding": {
|
||||
"chrome": "66",
|
||||
"opera": "53",
|
||||
"edge": "79",
|
||||
"firefox": "58",
|
||||
"safari": "11.1",
|
||||
"node": "10",
|
||||
"deno": "1",
|
||||
"ios": "11.3",
|
||||
"samsung": "9",
|
||||
"electron": "3.0"
|
||||
},
|
||||
"proposal-optional-catch-binding": {
|
||||
"chrome": "66",
|
||||
"opera": "53",
|
||||
@@ -102,6 +228,7 @@
|
||||
"firefox": "58",
|
||||
"safari": "11.1",
|
||||
"node": "10",
|
||||
"deno": "1",
|
||||
"ios": "11.3",
|
||||
"samsung": "9",
|
||||
"electron": "3.0"
|
||||
@@ -112,9 +239,22 @@
|
||||
"edge": "18",
|
||||
"firefox": "53",
|
||||
"node": "6",
|
||||
"deno": "1",
|
||||
"samsung": "5",
|
||||
"electron": "0.37"
|
||||
},
|
||||
"transform-async-generator-functions": {
|
||||
"chrome": "63",
|
||||
"opera": "50",
|
||||
"edge": "79",
|
||||
"firefox": "57",
|
||||
"safari": "12",
|
||||
"node": "10",
|
||||
"deno": "1",
|
||||
"ios": "12",
|
||||
"samsung": "8",
|
||||
"electron": "3.0"
|
||||
},
|
||||
"proposal-async-generator-functions": {
|
||||
"chrome": "63",
|
||||
"opera": "50",
|
||||
@@ -122,10 +262,23 @@
|
||||
"firefox": "57",
|
||||
"safari": "12",
|
||||
"node": "10",
|
||||
"deno": "1",
|
||||
"ios": "12",
|
||||
"samsung": "8",
|
||||
"electron": "3.0"
|
||||
},
|
||||
"transform-object-rest-spread": {
|
||||
"chrome": "60",
|
||||
"opera": "47",
|
||||
"edge": "79",
|
||||
"firefox": "55",
|
||||
"safari": "11.1",
|
||||
"node": "8.3",
|
||||
"deno": "1",
|
||||
"ios": "11.3",
|
||||
"samsung": "8",
|
||||
"electron": "2.0"
|
||||
},
|
||||
"proposal-object-rest-spread": {
|
||||
"chrome": "60",
|
||||
"opera": "47",
|
||||
@@ -133,6 +286,7 @@
|
||||
"firefox": "55",
|
||||
"safari": "11.1",
|
||||
"node": "8.3",
|
||||
"deno": "1",
|
||||
"ios": "11.3",
|
||||
"samsung": "8",
|
||||
"electron": "2.0"
|
||||
@@ -144,10 +298,23 @@
|
||||
"firefox": "78",
|
||||
"safari": "11.1",
|
||||
"node": "8.10",
|
||||
"deno": "1",
|
||||
"ios": "11.3",
|
||||
"samsung": "8",
|
||||
"electron": "3.0"
|
||||
},
|
||||
"transform-unicode-property-regex": {
|
||||
"chrome": "64",
|
||||
"opera": "51",
|
||||
"edge": "79",
|
||||
"firefox": "78",
|
||||
"safari": "11.1",
|
||||
"node": "10",
|
||||
"deno": "1",
|
||||
"ios": "11.3",
|
||||
"samsung": "9",
|
||||
"electron": "3.0"
|
||||
},
|
||||
"proposal-unicode-property-regex": {
|
||||
"chrome": "64",
|
||||
"opera": "51",
|
||||
@@ -155,6 +322,7 @@
|
||||
"firefox": "78",
|
||||
"safari": "11.1",
|
||||
"node": "10",
|
||||
"deno": "1",
|
||||
"ios": "11.3",
|
||||
"samsung": "9",
|
||||
"electron": "3.0"
|
||||
@@ -166,6 +334,7 @@
|
||||
"firefox": "78",
|
||||
"safari": "11.1",
|
||||
"node": "10",
|
||||
"deno": "1",
|
||||
"ios": "11.3",
|
||||
"samsung": "9",
|
||||
"electron": "3.0"
|
||||
@@ -177,6 +346,7 @@
|
||||
"firefox": "52",
|
||||
"safari": "11",
|
||||
"node": "7.6",
|
||||
"deno": "1",
|
||||
"ios": "11",
|
||||
"samsung": "6",
|
||||
"electron": "1.6"
|
||||
@@ -188,6 +358,7 @@
|
||||
"firefox": "52",
|
||||
"safari": "10.1",
|
||||
"node": "7",
|
||||
"deno": "1",
|
||||
"ios": "10.3",
|
||||
"samsung": "6",
|
||||
"rhino": "1.7.14",
|
||||
@@ -200,6 +371,7 @@
|
||||
"firefox": "34",
|
||||
"safari": "13",
|
||||
"node": "4",
|
||||
"deno": "1",
|
||||
"ios": "13",
|
||||
"samsung": "3.4",
|
||||
"electron": "0.21"
|
||||
@@ -211,6 +383,7 @@
|
||||
"firefox": "53",
|
||||
"safari": "9",
|
||||
"node": "4",
|
||||
"deno": "1",
|
||||
"ios": "9",
|
||||
"samsung": "4",
|
||||
"electron": "0.30"
|
||||
@@ -222,6 +395,7 @@
|
||||
"firefox": "53",
|
||||
"safari": "10",
|
||||
"node": "6.5",
|
||||
"deno": "1",
|
||||
"ios": "10",
|
||||
"samsung": "5",
|
||||
"electron": "1.2"
|
||||
@@ -233,6 +407,7 @@
|
||||
"firefox": "43",
|
||||
"safari": "10",
|
||||
"node": "6",
|
||||
"deno": "1",
|
||||
"ios": "10",
|
||||
"samsung": "5",
|
||||
"rhino": "1.7.13",
|
||||
@@ -245,6 +420,7 @@
|
||||
"firefox": "46",
|
||||
"safari": "10",
|
||||
"node": "4",
|
||||
"deno": "1",
|
||||
"ie": "11",
|
||||
"ios": "10",
|
||||
"samsung": "3.4",
|
||||
@@ -257,6 +433,7 @@
|
||||
"firefox": "45",
|
||||
"safari": "10",
|
||||
"node": "5",
|
||||
"deno": "1",
|
||||
"ios": "10",
|
||||
"samsung": "5",
|
||||
"electron": "0.36"
|
||||
@@ -268,6 +445,7 @@
|
||||
"firefox": "45",
|
||||
"safari": "10",
|
||||
"node": "5",
|
||||
"deno": "1",
|
||||
"ios": "10",
|
||||
"samsung": "5",
|
||||
"electron": "0.36"
|
||||
@@ -279,6 +457,7 @@
|
||||
"firefox": "33",
|
||||
"safari": "9",
|
||||
"node": "4",
|
||||
"deno": "1",
|
||||
"ios": "9",
|
||||
"samsung": "4",
|
||||
"rhino": "1.7.14",
|
||||
@@ -291,6 +470,7 @@
|
||||
"firefox": "34",
|
||||
"safari": "9",
|
||||
"node": "4",
|
||||
"deno": "1",
|
||||
"ios": "9",
|
||||
"samsung": "3.4",
|
||||
"electron": "0.25"
|
||||
@@ -302,6 +482,7 @@
|
||||
"firefox": "34",
|
||||
"safari": "7.1",
|
||||
"node": "4",
|
||||
"deno": "1",
|
||||
"ios": "8",
|
||||
"samsung": "4",
|
||||
"electron": "0.30"
|
||||
@@ -313,6 +494,7 @@
|
||||
"firefox": "53",
|
||||
"safari": "10",
|
||||
"node": "6.5",
|
||||
"deno": "1",
|
||||
"ios": "10",
|
||||
"samsung": "5",
|
||||
"electron": "1.2"
|
||||
@@ -324,6 +506,7 @@
|
||||
"firefox": "3",
|
||||
"safari": "10",
|
||||
"node": "6",
|
||||
"deno": "1",
|
||||
"ios": "10",
|
||||
"samsung": "5",
|
||||
"electron": "0.37"
|
||||
@@ -335,6 +518,7 @@
|
||||
"firefox": "53",
|
||||
"safari": "9",
|
||||
"node": "4",
|
||||
"deno": "1",
|
||||
"ios": "9",
|
||||
"samsung": "4",
|
||||
"electron": "0.30"
|
||||
@@ -346,6 +530,7 @@
|
||||
"firefox": "46",
|
||||
"safari": "12",
|
||||
"node": "6",
|
||||
"deno": "1",
|
||||
"ios": "12",
|
||||
"samsung": "5",
|
||||
"electron": "1.1"
|
||||
@@ -357,6 +542,7 @@
|
||||
"firefox": "45",
|
||||
"safari": "10",
|
||||
"node": "5",
|
||||
"deno": "1",
|
||||
"ios": "10",
|
||||
"samsung": "5",
|
||||
"electron": "0.36"
|
||||
@@ -368,6 +554,7 @@
|
||||
"firefox": "53",
|
||||
"safari": "10",
|
||||
"node": "6.5",
|
||||
"deno": "1",
|
||||
"ios": "10",
|
||||
"samsung": "5",
|
||||
"electron": "1.2"
|
||||
@@ -379,6 +566,7 @@
|
||||
"firefox": "51",
|
||||
"safari": "11",
|
||||
"node": "6",
|
||||
"deno": "1",
|
||||
"ios": "11",
|
||||
"samsung": "5",
|
||||
"electron": "0.37"
|
||||
@@ -390,6 +578,7 @@
|
||||
"firefox": "36",
|
||||
"safari": "9",
|
||||
"node": "0.12",
|
||||
"deno": "1",
|
||||
"ios": "9",
|
||||
"samsung": "3",
|
||||
"rhino": "1.7.13",
|
||||
@@ -402,6 +591,7 @@
|
||||
"firefox": "41",
|
||||
"safari": "10",
|
||||
"node": "5",
|
||||
"deno": "1",
|
||||
"ios": "10",
|
||||
"samsung": "5",
|
||||
"electron": "0.36"
|
||||
@@ -413,6 +603,7 @@
|
||||
"firefox": "53",
|
||||
"safari": "10",
|
||||
"node": "6",
|
||||
"deno": "1",
|
||||
"ios": "10",
|
||||
"samsung": "5",
|
||||
"electron": "1.1"
|
||||
@@ -424,6 +615,7 @@
|
||||
"firefox": "2",
|
||||
"safari": "5.1",
|
||||
"node": "0.4",
|
||||
"deno": "1",
|
||||
"ie": "9",
|
||||
"android": "4",
|
||||
"ios": "6",
|
||||
@@ -439,6 +631,7 @@
|
||||
"firefox": "2",
|
||||
"safari": "5.1",
|
||||
"node": "0.4",
|
||||
"deno": "1",
|
||||
"ie": "9",
|
||||
"android": "4",
|
||||
"ios": "6",
|
||||
@@ -454,6 +647,7 @@
|
||||
"firefox": "2",
|
||||
"safari": "3.1",
|
||||
"node": "0.6",
|
||||
"deno": "1",
|
||||
"ie": "9",
|
||||
"android": "4.4",
|
||||
"ios": "6",
|
||||
@@ -462,6 +656,19 @@
|
||||
"rhino": "1.7.13",
|
||||
"electron": "0.20"
|
||||
},
|
||||
"transform-export-namespace-from": {
|
||||
"chrome": "72",
|
||||
"and_chr": "72",
|
||||
"edge": "79",
|
||||
"firefox": "80",
|
||||
"and_ff": "80",
|
||||
"node": "13.2",
|
||||
"opera": "60",
|
||||
"op_mob": "51",
|
||||
"samsung": "11.0",
|
||||
"android": "72",
|
||||
"electron": "5.0"
|
||||
},
|
||||
"proposal-export-namespace-from": {
|
||||
"chrome": "72",
|
||||
"and_chr": "72",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/compat-data",
|
||||
"version": "7.19.3",
|
||||
"version": "7.20.0",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"license": "MIT",
|
||||
"description": "",
|
||||
|
||||
+1
-1
@@ -247,7 +247,7 @@ var _transformAst = require("./transform-ast");
|
||||
|
||||
var _parse = require("./parse");
|
||||
|
||||
const version = "7.19.3";
|
||||
const version = "7.19.6";
|
||||
exports.version = version;
|
||||
const DEFAULT_EXTENSIONS = Object.freeze([".js", ".jsx", ".es6", ".es", ".mjs", ".cjs"]);
|
||||
exports.DEFAULT_EXTENSIONS = DEFAULT_EXTENSIONS;
|
||||
|
||||
Generated
Vendored
+98
-98
@@ -11,46 +11,6 @@ const pluginNameMap = {
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-async-do-expressions"
|
||||
}
|
||||
},
|
||||
classProperties: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-class-properties",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-class-properties"
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-class-properties",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-class-properties"
|
||||
}
|
||||
},
|
||||
classPrivateProperties: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-class-properties",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-class-properties"
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-class-properties",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-class-properties"
|
||||
}
|
||||
},
|
||||
classPrivateMethods: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-class-properties",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-class-properties"
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-private-methods",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-private-methods"
|
||||
}
|
||||
},
|
||||
classStaticBlock: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-class-static-block",
|
||||
url: "https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-syntax-class-static-block"
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-class-static-block",
|
||||
url: "https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-proposal-class-static-block"
|
||||
}
|
||||
},
|
||||
decimal: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-decimal",
|
||||
@@ -77,12 +37,6 @@ const pluginNameMap = {
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-do-expressions"
|
||||
}
|
||||
},
|
||||
dynamicImport: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-dynamic-import",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-dynamic-import"
|
||||
}
|
||||
},
|
||||
exportDefaultFrom: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-export-default-from",
|
||||
@@ -93,16 +47,6 @@ const pluginNameMap = {
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-export-default-from"
|
||||
}
|
||||
},
|
||||
exportNamespaceFrom: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-export-namespace-from",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-export-namespace-from"
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-export-namespace-from",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-export-namespace-from"
|
||||
}
|
||||
},
|
||||
flow: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-flow",
|
||||
@@ -133,12 +77,6 @@ const pluginNameMap = {
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-function-sent"
|
||||
}
|
||||
},
|
||||
importMeta: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-import-meta",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-meta"
|
||||
}
|
||||
},
|
||||
jsx: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-jsx",
|
||||
@@ -155,32 +93,6 @@ const pluginNameMap = {
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-assertions"
|
||||
}
|
||||
},
|
||||
moduleStringNames: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-module-string-names",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-module-string-names"
|
||||
}
|
||||
},
|
||||
numericSeparator: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-numeric-separator",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-numeric-separator"
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-numeric-separator",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-numeric-separator"
|
||||
}
|
||||
},
|
||||
optionalChaining: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-optional-chaining",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-optional-chaining"
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-optional-chaining",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-optional-chaining"
|
||||
}
|
||||
},
|
||||
pipelineOperator: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-pipeline-operator",
|
||||
@@ -191,16 +103,6 @@ const pluginNameMap = {
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-pipeline-operator"
|
||||
}
|
||||
},
|
||||
privateIn: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-private-property-in-object",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-private-property-in-object"
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-private-property-in-object",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-private-property-in-object"
|
||||
}
|
||||
},
|
||||
recordAndTuple: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-record-and-tuple",
|
||||
@@ -247,6 +149,68 @@ const pluginNameMap = {
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-async-generator-functions"
|
||||
}
|
||||
},
|
||||
classProperties: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-class-properties",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-class-properties"
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-class-properties",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-class-properties"
|
||||
}
|
||||
},
|
||||
classPrivateProperties: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-class-properties",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-class-properties"
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-class-properties",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-class-properties"
|
||||
}
|
||||
},
|
||||
classPrivateMethods: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-class-properties",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-class-properties"
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-private-methods",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-private-methods"
|
||||
}
|
||||
},
|
||||
classStaticBlock: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-class-static-block",
|
||||
url: "https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-syntax-class-static-block"
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-class-static-block",
|
||||
url: "https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-proposal-class-static-block"
|
||||
}
|
||||
},
|
||||
dynamicImport: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-dynamic-import",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-dynamic-import"
|
||||
}
|
||||
},
|
||||
exportNamespaceFrom: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-export-namespace-from",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-export-namespace-from"
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-export-namespace-from",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-export-namespace-from"
|
||||
}
|
||||
},
|
||||
importMeta: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-import-meta",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-meta"
|
||||
}
|
||||
},
|
||||
logicalAssignment: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-logical-assignment-operators",
|
||||
@@ -257,6 +221,22 @@ const pluginNameMap = {
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-logical-assignment-operators"
|
||||
}
|
||||
},
|
||||
moduleStringNames: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-module-string-names",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-module-string-names"
|
||||
}
|
||||
},
|
||||
numericSeparator: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-numeric-separator",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-numeric-separator"
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-numeric-separator",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-numeric-separator"
|
||||
}
|
||||
},
|
||||
nullishCoalescingOperator: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-nullish-coalescing-operator",
|
||||
@@ -286,6 +266,26 @@ const pluginNameMap = {
|
||||
name: "@babel/plugin-proposal-optional-catch-binding",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-optional-catch-binding"
|
||||
}
|
||||
},
|
||||
optionalChaining: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-optional-chaining",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-optional-chaining"
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-optional-chaining",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-optional-chaining"
|
||||
}
|
||||
},
|
||||
privateIn: {
|
||||
syntax: {
|
||||
name: "@babel/plugin-syntax-private-property-in-object",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-private-property-in-object"
|
||||
},
|
||||
transform: {
|
||||
name: "@babel/plugin-proposal-private-property-in-object",
|
||||
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-private-property-in-object"
|
||||
}
|
||||
}
|
||||
};
|
||||
pluginNameMap.privateIn.syntax = pluginNameMap.privateIn.transform;
|
||||
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/core",
|
||||
"version": "7.19.3",
|
||||
"version": "7.19.6",
|
||||
"description": "Babel compiler core.",
|
||||
"main": "./lib/index.js",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
@@ -48,14 +48,14 @@
|
||||
"dependencies": {
|
||||
"@ampproject/remapping": "^2.1.0",
|
||||
"@babel/code-frame": "^7.18.6",
|
||||
"@babel/generator": "^7.19.3",
|
||||
"@babel/generator": "^7.19.6",
|
||||
"@babel/helper-compilation-targets": "^7.19.3",
|
||||
"@babel/helper-module-transforms": "^7.19.0",
|
||||
"@babel/helpers": "^7.19.0",
|
||||
"@babel/parser": "^7.19.3",
|
||||
"@babel/helper-module-transforms": "^7.19.6",
|
||||
"@babel/helpers": "^7.19.4",
|
||||
"@babel/parser": "^7.19.6",
|
||||
"@babel/template": "^7.18.10",
|
||||
"@babel/traverse": "^7.19.3",
|
||||
"@babel/types": "^7.19.3",
|
||||
"@babel/traverse": "^7.19.6",
|
||||
"@babel/types": "^7.19.4",
|
||||
"convert-source-map": "^1.7.0",
|
||||
"debug": "^4.1.0",
|
||||
"gensync": "^1.0.0-beta.2",
|
||||
@@ -63,11 +63,11 @@
|
||||
"semver": "^6.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-transform-fixture-test-runner": "^7.19.3",
|
||||
"@babel/helper-transform-fixture-test-runner": "^7.19.4",
|
||||
"@babel/plugin-syntax-flow": "^7.18.6",
|
||||
"@babel/plugin-transform-flow-strip-types": "^7.19.0",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
|
||||
"@babel/preset-env": "^7.19.3",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.19.6",
|
||||
"@babel/preset-env": "^7.19.4",
|
||||
"@jridgewell/trace-mapping": "^0.3.8",
|
||||
"@types/convert-source-map": "^1.5.1",
|
||||
"@types/debug": "^4.1.0",
|
||||
|
||||
+43
-55
@@ -5,15 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function SourcePos() {
|
||||
return {
|
||||
identifierName: undefined,
|
||||
line: undefined,
|
||||
column: undefined,
|
||||
filename: undefined
|
||||
};
|
||||
}
|
||||
|
||||
class Buffer {
|
||||
constructor(map) {
|
||||
this._map = null;
|
||||
@@ -27,13 +18,11 @@ class Buffer {
|
||||
line: 1,
|
||||
column: 0
|
||||
};
|
||||
this._sourcePosition = SourcePos();
|
||||
this._disallowedPop = {
|
||||
this._sourcePosition = {
|
||||
identifierName: undefined,
|
||||
line: undefined,
|
||||
column: undefined,
|
||||
filename: undefined,
|
||||
objectReusable: true
|
||||
filename: undefined
|
||||
};
|
||||
this._map = map;
|
||||
|
||||
@@ -181,6 +170,7 @@ class Buffer {
|
||||
|
||||
_append(str, sourcePos, maybeNewline) {
|
||||
const len = str.length;
|
||||
const position = this._position;
|
||||
this._last = str.charCodeAt(len - 1);
|
||||
|
||||
if (++this._appendCount > 4096) {
|
||||
@@ -193,7 +183,7 @@ class Buffer {
|
||||
}
|
||||
|
||||
if (!maybeNewline && !this._map) {
|
||||
this._position.column += len;
|
||||
position.column += len;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -211,18 +201,18 @@ class Buffer {
|
||||
}
|
||||
|
||||
while (i !== -1) {
|
||||
this._position.line++;
|
||||
this._position.column = 0;
|
||||
position.line++;
|
||||
position.column = 0;
|
||||
last = i + 1;
|
||||
|
||||
if (last < str.length) {
|
||||
if (last < len) {
|
||||
this._mark(++line, 0, identifierName, filename);
|
||||
}
|
||||
|
||||
i = str.indexOf("\n", last);
|
||||
}
|
||||
|
||||
this._position.column += str.length - last;
|
||||
position.column += len - last;
|
||||
}
|
||||
|
||||
_mark(line, column, identifierName, filename) {
|
||||
@@ -252,6 +242,22 @@ class Buffer {
|
||||
return queueCursor !== 0 ? this._queue[queueCursor - 1].char : this._last;
|
||||
}
|
||||
|
||||
getNewlineCount() {
|
||||
const queueCursor = this._queueCursor;
|
||||
let count = 0;
|
||||
if (queueCursor === 0) return this._last === 10 ? 1 : 0;
|
||||
|
||||
for (let i = queueCursor - 1; i >= 0; i--) {
|
||||
if (this._queue[i].char !== 10) {
|
||||
break;
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
return count === queueCursor && this._last === 10 ? count + 1 : count;
|
||||
}
|
||||
|
||||
endsWithCharAndNewline() {
|
||||
const queue = this._queue;
|
||||
const queueCursor = this._queueCursor;
|
||||
@@ -277,70 +283,52 @@ class Buffer {
|
||||
this.source("start", loc);
|
||||
cb();
|
||||
this.source("end", loc);
|
||||
|
||||
this._disallowPop("start", loc);
|
||||
}
|
||||
|
||||
source(prop, loc) {
|
||||
if (!loc) return;
|
||||
if (!this._map) return;
|
||||
|
||||
this._normalizePosition(prop, loc, this._sourcePosition);
|
||||
this._normalizePosition(prop, loc, 0, 0);
|
||||
}
|
||||
|
||||
sourceWithOffset(prop, loc, lineOffset, columnOffset) {
|
||||
if (!this._map) return;
|
||||
|
||||
this._normalizePosition(prop, loc, lineOffset, columnOffset);
|
||||
}
|
||||
|
||||
withSource(prop, loc, cb) {
|
||||
if (!this._map) return cb();
|
||||
const originalLine = this._sourcePosition.line;
|
||||
const originalColumn = this._sourcePosition.column;
|
||||
const originalFilename = this._sourcePosition.filename;
|
||||
const originalIdentifierName = this._sourcePosition.identifierName;
|
||||
this.source(prop, loc);
|
||||
cb();
|
||||
|
||||
if (this._disallowedPop.objectReusable || this._disallowedPop.line !== originalLine || this._disallowedPop.column !== originalColumn || this._disallowedPop.filename !== originalFilename) {
|
||||
this._sourcePosition.line = originalLine;
|
||||
this._sourcePosition.column = originalColumn;
|
||||
this._sourcePosition.filename = originalFilename;
|
||||
this._sourcePosition.identifierName = originalIdentifierName;
|
||||
this._disallowedPop.objectReusable = true;
|
||||
}
|
||||
}
|
||||
|
||||
_disallowPop(prop, loc) {
|
||||
if (!loc) return;
|
||||
const disallowedPop = this._disallowedPop;
|
||||
|
||||
this._normalizePosition(prop, loc, disallowedPop);
|
||||
|
||||
disallowedPop.objectReusable = false;
|
||||
}
|
||||
|
||||
_normalizePosition(prop, loc, targetObj) {
|
||||
_normalizePosition(prop, loc, lineOffset, columnOffset) {
|
||||
const pos = loc[prop];
|
||||
targetObj.identifierName = prop === "start" && loc.identifierName || undefined;
|
||||
const target = this._sourcePosition;
|
||||
target.identifierName = prop === "start" && loc.identifierName || undefined;
|
||||
|
||||
if (pos) {
|
||||
targetObj.line = pos.line;
|
||||
targetObj.column = pos.column;
|
||||
targetObj.filename = loc.filename;
|
||||
} else {
|
||||
targetObj.line = null;
|
||||
targetObj.column = null;
|
||||
targetObj.filename = null;
|
||||
target.line = pos.line + lineOffset;
|
||||
target.column = pos.column + columnOffset;
|
||||
target.filename = loc.filename;
|
||||
}
|
||||
}
|
||||
|
||||
getCurrentColumn() {
|
||||
const queue = this._queue;
|
||||
const queueCursor = this._queueCursor;
|
||||
let lastIndex = -1;
|
||||
let len = 0;
|
||||
|
||||
for (let i = 0; i < this._queueCursor; i++) {
|
||||
for (let i = 0; i < queueCursor; i++) {
|
||||
const item = queue[i];
|
||||
|
||||
if (item.char === 10) {
|
||||
lastIndex = i;
|
||||
len += item.repeat;
|
||||
lastIndex = len;
|
||||
}
|
||||
|
||||
len += item.repeat;
|
||||
}
|
||||
|
||||
return lastIndex === -1 ? this._position.column + len : len - 1 - lastIndex;
|
||||
|
||||
+37
-19
@@ -20,36 +20,53 @@ function File(node) {
|
||||
}
|
||||
|
||||
function Program(node) {
|
||||
var _node$directives;
|
||||
|
||||
this.printInnerComments(node, false);
|
||||
this.printSequence(node.directives, node);
|
||||
if (node.directives && node.directives.length) this.newline();
|
||||
const directivesLen = (_node$directives = node.directives) == null ? void 0 : _node$directives.length;
|
||||
|
||||
if (directivesLen) {
|
||||
var _node$directives$trai;
|
||||
|
||||
const newline = node.body.length ? 2 : 1;
|
||||
this.printSequence(node.directives, node, {
|
||||
trailingCommentsLineOffset: newline
|
||||
});
|
||||
|
||||
if (!((_node$directives$trai = node.directives[directivesLen - 1].trailingComments) != null && _node$directives$trai.length)) {
|
||||
this.newline(newline);
|
||||
}
|
||||
}
|
||||
|
||||
this.printSequence(node.body, node);
|
||||
}
|
||||
|
||||
function BlockStatement(node) {
|
||||
var _node$directives;
|
||||
var _node$directives2;
|
||||
|
||||
this.tokenChar(123);
|
||||
this.printInnerComments(node);
|
||||
const hasDirectives = (_node$directives = node.directives) == null ? void 0 : _node$directives.length;
|
||||
const directivesLen = (_node$directives2 = node.directives) == null ? void 0 : _node$directives2.length;
|
||||
|
||||
if (node.body.length || hasDirectives) {
|
||||
this.newline();
|
||||
if (directivesLen) {
|
||||
var _node$directives$trai2;
|
||||
|
||||
const newline = node.body.length ? 2 : 1;
|
||||
this.printSequence(node.directives, node, {
|
||||
indent: true
|
||||
indent: true,
|
||||
trailingCommentsLineOffset: newline
|
||||
});
|
||||
if (hasDirectives) this.newline();
|
||||
this.printSequence(node.body, node, {
|
||||
indent: true
|
||||
});
|
||||
this.removeTrailingNewline();
|
||||
this.source("end", node.loc);
|
||||
if (!this.endsWith(10)) this.newline();
|
||||
this.rightBrace();
|
||||
} else {
|
||||
this.source("end", node.loc);
|
||||
this.tokenChar(125);
|
||||
|
||||
if (!((_node$directives$trai2 = node.directives[directivesLen - 1].trailingComments) != null && _node$directives$trai2.length)) {
|
||||
this.newline(newline);
|
||||
}
|
||||
}
|
||||
|
||||
this.printSequence(node.body, node, {
|
||||
indent: true
|
||||
});
|
||||
this.sourceWithOffset("end", node.loc, 0, -1);
|
||||
this.rightBrace();
|
||||
}
|
||||
|
||||
function Directive(node) {
|
||||
@@ -82,7 +99,8 @@ function DirectiveLiteral(node) {
|
||||
}
|
||||
|
||||
function InterpreterDirective(node) {
|
||||
this.token(`#!${node.value}\n`, true);
|
||||
this.token(`#!${node.value}`);
|
||||
this.newline(1, true);
|
||||
}
|
||||
|
||||
function Placeholder(node) {
|
||||
|
||||
Generated
Vendored
+14
-3
@@ -78,13 +78,17 @@ function ClassBody(node) {
|
||||
this.printSequence(node.body, node);
|
||||
this.dedent();
|
||||
if (!this.endsWith(10)) this.newline();
|
||||
this.sourceWithOffset("end", node.loc, 0, -1);
|
||||
this.rightBrace();
|
||||
}
|
||||
}
|
||||
|
||||
function ClassProperty(node) {
|
||||
var _node$key$loc, _node$key$loc$end;
|
||||
|
||||
this.printJoin(node.decorators, node);
|
||||
this.source("end", node.key.loc);
|
||||
const endLine = (_node$key$loc = node.key.loc) == null ? void 0 : (_node$key$loc$end = _node$key$loc.end) == null ? void 0 : _node$key$loc$end.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
this.tsPrintClassMemberModifiers(node);
|
||||
|
||||
if (node.computed) {
|
||||
@@ -118,8 +122,11 @@ function ClassProperty(node) {
|
||||
}
|
||||
|
||||
function ClassAccessorProperty(node) {
|
||||
var _node$key$loc2, _node$key$loc2$end;
|
||||
|
||||
this.printJoin(node.decorators, node);
|
||||
this.source("end", node.key.loc);
|
||||
const endLine = (_node$key$loc2 = node.key.loc) == null ? void 0 : (_node$key$loc2$end = _node$key$loc2.end) == null ? void 0 : _node$key$loc2$end.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
this.tsPrintClassMemberModifiers(node);
|
||||
this.word("accessor");
|
||||
this.printInnerComments(node);
|
||||
@@ -191,8 +198,11 @@ function ClassPrivateMethod(node) {
|
||||
}
|
||||
|
||||
function _classMethodHead(node) {
|
||||
var _node$key$loc3, _node$key$loc3$end;
|
||||
|
||||
this.printJoin(node.decorators, node);
|
||||
this.source("end", node.key.loc);
|
||||
const endLine = (_node$key$loc3 = node.key.loc) == null ? void 0 : (_node$key$loc3$end = _node$key$loc3.end) == null ? void 0 : _node$key$loc3$end.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
this.tsPrintClassMemberModifiers(node);
|
||||
|
||||
this._methodHead(node);
|
||||
@@ -210,6 +220,7 @@ function StaticBlock(node) {
|
||||
this.printSequence(node.body, node, {
|
||||
indent: true
|
||||
});
|
||||
this.sourceWithOffset("end", node.loc, 0, -1);
|
||||
this.rightBrace();
|
||||
}
|
||||
}
|
||||
|
||||
Generated
Vendored
+30
-13
@@ -55,7 +55,10 @@ function UnaryExpression(node) {
|
||||
function DoExpression(node) {
|
||||
if (node.async) {
|
||||
this.word("async");
|
||||
this.space();
|
||||
this.ensureNoLineTerminator(() => {
|
||||
this.printInnerComments(node);
|
||||
this.space();
|
||||
});
|
||||
}
|
||||
|
||||
this.word("do");
|
||||
@@ -234,12 +237,20 @@ function YieldExpression(node) {
|
||||
this.word("yield");
|
||||
|
||||
if (node.delegate) {
|
||||
this.ensureNoLineTerminator(() => {
|
||||
this.printInnerComments(node);
|
||||
});
|
||||
this.tokenChar(42);
|
||||
}
|
||||
|
||||
if (node.argument) {
|
||||
this.space();
|
||||
this.printTerminatorless(node.argument, node, false);
|
||||
if (node.argument) {
|
||||
this.space();
|
||||
this.print(node.argument, node);
|
||||
}
|
||||
} else {
|
||||
if (node.argument) {
|
||||
this.space();
|
||||
this.printTerminatorless(node.argument, node, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,18 +344,24 @@ function V8IntrinsicIdentifier(node) {
|
||||
|
||||
function ModuleExpression(node) {
|
||||
this.word("module");
|
||||
this.space();
|
||||
this.ensureNoLineTerminator(() => {
|
||||
this.printInnerComments(node);
|
||||
this.space();
|
||||
});
|
||||
this.tokenChar(123);
|
||||
this.indent();
|
||||
const {
|
||||
body
|
||||
} = node;
|
||||
|
||||
if (node.body.body.length === 0) {
|
||||
this.tokenChar(125);
|
||||
} else {
|
||||
if (body.body.length || body.directives.length) {
|
||||
this.newline();
|
||||
this.printSequence(node.body.body, node, {
|
||||
indent: true
|
||||
});
|
||||
this.rightBrace();
|
||||
}
|
||||
|
||||
this.print(body, node);
|
||||
this.dedent();
|
||||
this.sourceWithOffset("end", node.loc, 0, -1);
|
||||
this.rightBrace();
|
||||
}
|
||||
|
||||
//# sourceMappingURL=expressions.js.map
|
||||
+1
@@ -611,6 +611,7 @@ function ObjectTypeAnnotation(node) {
|
||||
const props = [...node.properties, ...(node.callProperties || []), ...(node.indexers || []), ...(node.internalSlots || [])];
|
||||
|
||||
if (props.length) {
|
||||
this.newline();
|
||||
this.space();
|
||||
this.printJoin(props, node, {
|
||||
addNewlines(leading) {
|
||||
|
||||
Generated
Vendored
+35
-7
@@ -29,7 +29,9 @@ function _params(node) {
|
||||
}
|
||||
|
||||
function _parameters(parameters, parent) {
|
||||
for (let i = 0; i < parameters.length; i++) {
|
||||
const paramLength = parameters.length;
|
||||
|
||||
for (let i = 0; i < paramLength; i++) {
|
||||
this._param(parameters[i], parent);
|
||||
|
||||
if (i < parameters.length - 1) {
|
||||
@@ -37,6 +39,10 @@ function _parameters(parameters, parent) {
|
||||
this.space();
|
||||
}
|
||||
}
|
||||
|
||||
if (paramLength === 0) {
|
||||
this.printInnerComments(parent);
|
||||
}
|
||||
}
|
||||
|
||||
function _param(parameter, parent) {
|
||||
@@ -59,25 +65,36 @@ function _methodHead(node) {
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.async) {
|
||||
this._catchUp("start", key.loc);
|
||||
const {
|
||||
_noLineTerminator
|
||||
} = this;
|
||||
|
||||
if (node.async) {
|
||||
this._noLineTerminator = true;
|
||||
this.word("async");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (kind === "method" || kind === "init") {
|
||||
if (node.generator) {
|
||||
if (node.async) {
|
||||
this.printInnerComments(node);
|
||||
}
|
||||
|
||||
this.tokenChar(42);
|
||||
this._noLineTerminator = _noLineTerminator;
|
||||
}
|
||||
}
|
||||
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this._noLineTerminator = _noLineTerminator;
|
||||
this.print(key, node);
|
||||
this.tokenChar(93);
|
||||
this.printInnerComments(node);
|
||||
} else {
|
||||
this.print(key, node);
|
||||
this._noLineTerminator = _noLineTerminator;
|
||||
}
|
||||
|
||||
if (node.optional) {
|
||||
@@ -128,23 +145,34 @@ function FunctionExpression(node) {
|
||||
}
|
||||
|
||||
function ArrowFunctionExpression(node) {
|
||||
const {
|
||||
_noLineTerminator
|
||||
} = this;
|
||||
|
||||
if (node.async) {
|
||||
this._noLineTerminator = true;
|
||||
this.word("async");
|
||||
this.space();
|
||||
}
|
||||
|
||||
const firstParam = node.params[0];
|
||||
let firstParam;
|
||||
|
||||
if (!this.format.retainLines && !this.format.auxiliaryCommentBefore && !this.format.auxiliaryCommentAfter && node.params.length === 1 && isIdentifier(firstParam) && !hasTypesOrComments(node, firstParam)) {
|
||||
if (!this.format.retainLines && node.params.length === 1 && isIdentifier(firstParam = node.params[0]) && !hasTypesOrComments(node, firstParam)) {
|
||||
this.print(firstParam, node);
|
||||
this._noLineTerminator = _noLineTerminator;
|
||||
} else {
|
||||
this._noLineTerminator = _noLineTerminator;
|
||||
|
||||
this._params(node);
|
||||
}
|
||||
|
||||
this._predicate(node);
|
||||
|
||||
this.space();
|
||||
this.token("=>");
|
||||
this.ensureNoLineTerminator(() => {
|
||||
this.space();
|
||||
this.printInnerComments(node);
|
||||
this.token("=>");
|
||||
});
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
Generated
Vendored
+46
-6
@@ -75,6 +75,8 @@ function ExportNamespaceSpecifier(node) {
|
||||
}
|
||||
|
||||
function ExportAllDeclaration(node) {
|
||||
var _node$assertions;
|
||||
|
||||
this.word("export");
|
||||
this.space();
|
||||
|
||||
@@ -87,8 +89,18 @@ function ExportAllDeclaration(node) {
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
this.print(node.source, node);
|
||||
this.printAssertions(node);
|
||||
|
||||
if ((_node$assertions = node.assertions) != null && _node$assertions.length) {
|
||||
this.ensureNoLineTerminator(() => {
|
||||
this.print(node.source, node);
|
||||
this.space();
|
||||
this.word("assert");
|
||||
});
|
||||
this.printAssertions(node);
|
||||
} else {
|
||||
this.print(node.source, node);
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
@@ -143,11 +155,22 @@ function ExportNamedDeclaration(node) {
|
||||
}
|
||||
|
||||
if (node.source) {
|
||||
var _node$assertions2;
|
||||
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
this.print(node.source, node);
|
||||
this.printAssertions(node);
|
||||
|
||||
if ((_node$assertions2 = node.assertions) != null && _node$assertions2.length) {
|
||||
this.ensureNoLineTerminator(() => {
|
||||
this.print(node.source, node);
|
||||
this.space();
|
||||
this.word("assert");
|
||||
});
|
||||
this.printAssertions(node);
|
||||
} else {
|
||||
this.print(node.source, node);
|
||||
}
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
@@ -161,6 +184,7 @@ function ExportDefaultDeclaration(node) {
|
||||
}
|
||||
}
|
||||
this.word("export");
|
||||
this.printInnerComments(node);
|
||||
this.space();
|
||||
this.word("default");
|
||||
this.space();
|
||||
@@ -170,13 +194,20 @@ function ExportDefaultDeclaration(node) {
|
||||
}
|
||||
|
||||
function ImportDeclaration(node) {
|
||||
var _node$assertions3;
|
||||
|
||||
this.word("import");
|
||||
this.space();
|
||||
const isTypeKind = node.importKind === "type" || node.importKind === "typeof";
|
||||
|
||||
if (isTypeKind) {
|
||||
this.printInnerComments(node, false);
|
||||
this.word(node.importKind);
|
||||
this.space();
|
||||
} else if (node.module) {
|
||||
this.printInnerComments(node, false);
|
||||
this.word("module");
|
||||
this.space();
|
||||
}
|
||||
|
||||
const specifiers = node.specifiers.slice(0);
|
||||
@@ -214,8 +245,17 @@ function ImportDeclaration(node) {
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.source, node);
|
||||
this.printAssertions(node);
|
||||
if ((_node$assertions3 = node.assertions) != null && _node$assertions3.length) {
|
||||
this.print(node.source, node, true);
|
||||
this.ensureNoLineTerminator(() => {
|
||||
this.space();
|
||||
this.word("assert");
|
||||
});
|
||||
this.printAssertions(node);
|
||||
} else {
|
||||
this.print(node.source, node);
|
||||
}
|
||||
|
||||
{
|
||||
var _node$attributes;
|
||||
|
||||
|
||||
Generated
Vendored
+26
-23
@@ -127,6 +127,7 @@ function ForXStatement(node) {
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.printInnerComments(node, false);
|
||||
this.tokenChar(40);
|
||||
this.print(node.left, node);
|
||||
this.space();
|
||||
@@ -269,31 +270,24 @@ function DebuggerStatement() {
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function variableDeclarationIndent() {
|
||||
this.tokenChar(44);
|
||||
this.newline();
|
||||
|
||||
if (this.endsWith(10)) {
|
||||
for (let i = 0; i < 4; i++) this.space(true);
|
||||
}
|
||||
}
|
||||
|
||||
function constDeclarationIndent() {
|
||||
this.tokenChar(44);
|
||||
this.newline();
|
||||
|
||||
if (this.endsWith(10)) {
|
||||
for (let i = 0; i < 6; i++) this.space(true);
|
||||
}
|
||||
}
|
||||
|
||||
function VariableDeclaration(node, parent) {
|
||||
if (node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word(node.kind);
|
||||
const {
|
||||
kind
|
||||
} = node;
|
||||
this.word(kind);
|
||||
const {
|
||||
_noLineTerminator
|
||||
} = this;
|
||||
|
||||
if (kind === "using") {
|
||||
this._noLineTerminator = true;
|
||||
}
|
||||
|
||||
this.space();
|
||||
let hasInits = false;
|
||||
|
||||
@@ -305,14 +299,23 @@ function VariableDeclaration(node, parent) {
|
||||
}
|
||||
}
|
||||
|
||||
let separator;
|
||||
let iterator;
|
||||
|
||||
if (hasInits) {
|
||||
separator = node.kind === "const" ? constDeclarationIndent : variableDeclarationIndent;
|
||||
if (kind === "using") {
|
||||
iterator = (_, i) => {
|
||||
if (i === 0) {
|
||||
this._noLineTerminator = _noLineTerminator;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
this.printList(node.declarations, node, {
|
||||
separator
|
||||
separator: hasInits ? function () {
|
||||
this.tokenChar(44);
|
||||
this.newline();
|
||||
} : undefined,
|
||||
iterator,
|
||||
indent: node.declarations.length > 1 ? true : false
|
||||
});
|
||||
|
||||
if (isFor(parent)) {
|
||||
|
||||
+2
-3
@@ -34,9 +34,7 @@ const {
|
||||
} = _t;
|
||||
|
||||
function Identifier(node) {
|
||||
this.exactSource(node.loc, () => {
|
||||
this.word(node.name);
|
||||
});
|
||||
this.word(node.name);
|
||||
}
|
||||
|
||||
function ArgumentPlaceholder() {
|
||||
@@ -62,6 +60,7 @@ function ObjectExpression(node) {
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.sourceWithOffset("end", node.loc, 0, -1);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
|
||||
Generated
Vendored
+11
-7
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
exports.TSAnyKeyword = TSAnyKeyword;
|
||||
exports.TSArrayType = TSArrayType;
|
||||
exports.TSAsExpression = TSAsExpression;
|
||||
exports.TSSatisfiesExpression = exports.TSAsExpression = TSTypeExpression;
|
||||
exports.TSBigIntKeyword = TSBigIntKeyword;
|
||||
exports.TSBooleanKeyword = TSBooleanKeyword;
|
||||
exports.TSCallSignatureDeclaration = TSCallSignatureDeclaration;
|
||||
@@ -388,10 +388,10 @@ function tsPrintBraced(printer, members, node) {
|
||||
}
|
||||
|
||||
printer.dedent();
|
||||
printer.rightBrace();
|
||||
} else {
|
||||
printer.token("}");
|
||||
}
|
||||
|
||||
printer.sourceWithOffset("end", node.loc, 0, -1);
|
||||
printer.rightBrace();
|
||||
}
|
||||
|
||||
function TSArrayType(node) {
|
||||
@@ -600,14 +600,18 @@ function TSTypeAliasDeclaration(node) {
|
||||
this.tokenChar(59);
|
||||
}
|
||||
|
||||
function TSAsExpression(node) {
|
||||
function TSTypeExpression(node) {
|
||||
var _expression$trailingC;
|
||||
|
||||
const {
|
||||
type,
|
||||
expression,
|
||||
typeAnnotation
|
||||
} = node;
|
||||
this.print(expression, node);
|
||||
const forceParens = !!((_expression$trailingC = expression.trailingComments) != null && _expression$trailingC.length);
|
||||
this.print(expression, node, true, undefined, forceParens);
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.word(type === "TSAsExpression" ? "as" : "satisfies");
|
||||
this.space();
|
||||
this.print(typeAnnotation, node);
|
||||
}
|
||||
|
||||
+4
-8
@@ -19,10 +19,9 @@ exports.ObjectExpression = ObjectExpression;
|
||||
exports.OptionalIndexedAccessType = OptionalIndexedAccessType;
|
||||
exports.OptionalCallExpression = exports.OptionalMemberExpression = OptionalMemberExpression;
|
||||
exports.SequenceExpression = SequenceExpression;
|
||||
exports.TSAsExpression = TSAsExpression;
|
||||
exports.TSTypeAssertion = exports.TSSatisfiesExpression = exports.TSAsExpression = TSAsExpression;
|
||||
exports.TSInferType = TSInferType;
|
||||
exports.TSInstantiationExpression = TSInstantiationExpression;
|
||||
exports.TSTypeAssertion = TSTypeAssertion;
|
||||
exports.TSIntersectionType = exports.TSUnionType = TSUnionType;
|
||||
exports.UnaryLike = UnaryLike;
|
||||
exports.IntersectionTypeAnnotation = exports.UnionTypeAnnotation = UnionTypeAnnotation;
|
||||
@@ -81,7 +80,8 @@ const {
|
||||
isUnionTypeAnnotation,
|
||||
isVariableDeclarator,
|
||||
isWhileStatement,
|
||||
isYieldExpression
|
||||
isYieldExpression,
|
||||
isTSSatisfiesExpression
|
||||
} = _t;
|
||||
const PRECEDENCE = {
|
||||
"||": 0,
|
||||
@@ -180,10 +180,6 @@ function TSAsExpression() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function TSTypeAssertion() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function TSUnionType(node, parent) {
|
||||
return isTSArrayType(parent) || isTSOptionalType(parent) || isTSIntersectionType(parent) || isTSUnionType(parent) || isTSRestType(parent);
|
||||
}
|
||||
@@ -234,7 +230,7 @@ function ArrowFunctionExpression(node, parent) {
|
||||
function ConditionalExpression(node, parent) {
|
||||
if (isUnaryLike(parent) || isBinary(parent) || isConditionalExpression(parent, {
|
||||
test: node
|
||||
}) || isAwaitExpression(parent) || isTSTypeAssertion(parent) || isTSAsExpression(parent)) {
|
||||
}) || isAwaitExpression(parent) || isTSTypeAssertion(parent) || isTSAsExpression(parent) || isTSSatisfiesExpression(parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+239
-83
@@ -9,16 +9,22 @@ var _buffer = require("./buffer");
|
||||
|
||||
var n = require("./node");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var generatorFunctions = require("./generators");
|
||||
|
||||
const {
|
||||
isFunction,
|
||||
isStatement,
|
||||
isClassBody,
|
||||
isTSInterfaceBody
|
||||
} = _t;
|
||||
const SCIENTIFIC_NOTATION = /e/i;
|
||||
const ZERO_DECIMAL_INTEGER = /\.0+$/;
|
||||
const NON_DECIMAL_LITERAL = /^0[box]/;
|
||||
const PURE_ANNOTATION_RE = /^\s*[@#]__PURE__\s*$/;
|
||||
const {
|
||||
needsParens,
|
||||
needsWhitespaceAfter,
|
||||
needsWhitespaceBefore
|
||||
needsParens
|
||||
} = n;
|
||||
|
||||
class Printer {
|
||||
@@ -35,6 +41,7 @@ class Printer {
|
||||
this._printedComments = new Set();
|
||||
this._endsWithInteger = false;
|
||||
this._endsWithWord = false;
|
||||
this._lastCommentLine = 0;
|
||||
this.format = format;
|
||||
this._buf = new _buffer.default(map);
|
||||
this._indentChar = format.indent.style.charCodeAt(0);
|
||||
@@ -133,26 +140,26 @@ class Printer {
|
||||
this._appendChar(char);
|
||||
}
|
||||
|
||||
newline(i = 1) {
|
||||
if (this.format.retainLines || this.format.compact) return;
|
||||
|
||||
if (this.format.concise) {
|
||||
this.space();
|
||||
return;
|
||||
}
|
||||
|
||||
const charBeforeNewline = this.endsWithCharAndNewline();
|
||||
if (charBeforeNewline === 10) return;
|
||||
|
||||
if (charBeforeNewline === 123 || charBeforeNewline === 58) {
|
||||
i--;
|
||||
}
|
||||
|
||||
newline(i = 1, force) {
|
||||
if (i <= 0) return;
|
||||
|
||||
if (!force) {
|
||||
if (this.format.retainLines || this.format.compact) return;
|
||||
|
||||
if (this.format.concise) {
|
||||
this.space();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (i > 2) i = 2;
|
||||
i -= this._buf.getNewlineCount();
|
||||
|
||||
for (let j = 0; j < i; j++) {
|
||||
this._newline();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
endsWith(char) {
|
||||
@@ -172,18 +179,32 @@ class Printer {
|
||||
}
|
||||
|
||||
exactSource(loc, cb) {
|
||||
if (!loc) return cb();
|
||||
|
||||
this._catchUp("start", loc);
|
||||
|
||||
this._buf.exactSource(loc, cb);
|
||||
}
|
||||
|
||||
source(prop, loc) {
|
||||
if (!loc) return;
|
||||
|
||||
this._catchUp(prop, loc);
|
||||
|
||||
this._buf.source(prop, loc);
|
||||
}
|
||||
|
||||
sourceWithOffset(prop, loc, lineOffset, columnOffset) {
|
||||
if (!loc) return;
|
||||
|
||||
this._catchUp(prop, loc);
|
||||
|
||||
this._buf.sourceWithOffset(prop, loc, lineOffset, columnOffset);
|
||||
}
|
||||
|
||||
withSource(prop, loc, cb) {
|
||||
if (!loc) return cb();
|
||||
|
||||
this._catchUp(prop, loc);
|
||||
|
||||
this._buf.withSource(prop, loc, cb);
|
||||
@@ -236,6 +257,12 @@ class Printer {
|
||||
}
|
||||
}
|
||||
|
||||
_shouldIndent(firstChar) {
|
||||
if (this._indent && firstChar !== 10 && this.endsWith(10)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
_maybeAddParenChar(char) {
|
||||
const parenPushNewlineState = this._parenPushNewlineState;
|
||||
if (!parenPushNewlineState) return;
|
||||
@@ -291,6 +318,16 @@ class Printer {
|
||||
parenPushNewlineState.printed = true;
|
||||
}
|
||||
|
||||
catchUp(line) {
|
||||
if (!this.format.retainLines) return;
|
||||
|
||||
const count = line - this._buf.getCurrentLine();
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
this._newline();
|
||||
}
|
||||
}
|
||||
|
||||
_catchUp(prop, loc) {
|
||||
if (!this.format.retainLines) return;
|
||||
const pos = loc ? loc[prop] : null;
|
||||
@@ -308,11 +345,20 @@ class Printer {
|
||||
return this._indentRepeat * this._indent;
|
||||
}
|
||||
|
||||
ensureNoLineTerminator(fn) {
|
||||
const {
|
||||
_noLineTerminator
|
||||
} = this;
|
||||
this._noLineTerminator = true;
|
||||
fn();
|
||||
this._noLineTerminator = _noLineTerminator;
|
||||
}
|
||||
|
||||
printTerminatorless(node, parent, isLabel) {
|
||||
if (isLabel) {
|
||||
this._noLineTerminator = true;
|
||||
this.print(node, parent);
|
||||
this._noLineTerminator = false;
|
||||
this.ensureNoLineTerminator(() => {
|
||||
this.print(node, parent);
|
||||
});
|
||||
} else {
|
||||
const terminatorState = {
|
||||
printed: false
|
||||
@@ -328,7 +374,7 @@ class Printer {
|
||||
}
|
||||
}
|
||||
|
||||
print(node, parent, noLineTerminator) {
|
||||
print(node, parent, noLineTerminator, trailingCommentsLineOffset, forceParens) {
|
||||
if (!node) return;
|
||||
const nodeType = node.type;
|
||||
const format = this.format;
|
||||
@@ -351,29 +397,32 @@ class Printer {
|
||||
|
||||
this._maybeAddAuxComment(this._insideAux && !oldInAux);
|
||||
|
||||
let shouldPrintParens;
|
||||
let shouldPrintParens = false;
|
||||
|
||||
if (format.retainFunctionParens && nodeType === "FunctionExpression" && node.extra && node.extra.parenthesized) {
|
||||
if (forceParens) {
|
||||
shouldPrintParens = true;
|
||||
} else if (format.retainFunctionParens && nodeType === "FunctionExpression" && node.extra && node.extra.parenthesized) {
|
||||
shouldPrintParens = true;
|
||||
} else {
|
||||
shouldPrintParens = needsParens(node, parent, this._printStack);
|
||||
}
|
||||
|
||||
if (shouldPrintParens) this.tokenChar(40);
|
||||
this._lastCommentLine = 0;
|
||||
|
||||
this._printLeadingComments(node);
|
||||
this._printLeadingComments(node, parent);
|
||||
|
||||
const loc = nodeType === "Program" || nodeType === "File" ? null : node.loc;
|
||||
this.withSource("start", loc, printMethod.bind(this, node, parent));
|
||||
this.exactSource(loc, printMethod.bind(this, node, parent));
|
||||
|
||||
if (noLineTerminator && !this._noLineTerminator) {
|
||||
this._noLineTerminator = true;
|
||||
|
||||
this._printTrailingComments(node);
|
||||
this._printTrailingComments(node, parent);
|
||||
|
||||
this._noLineTerminator = false;
|
||||
} else {
|
||||
this._printTrailingComments(node);
|
||||
this._printTrailingComments(node, parent, trailingCommentsLineOffset);
|
||||
}
|
||||
|
||||
if (shouldPrintParens) this.tokenChar(41);
|
||||
@@ -398,7 +447,7 @@ class Printer {
|
||||
this._printComment({
|
||||
type: "CommentBlock",
|
||||
value: comment
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,7 +460,7 @@ class Printer {
|
||||
this._printComment({
|
||||
type: "CommentBlock",
|
||||
value: comment
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,25 +476,32 @@ class Printer {
|
||||
if (!(nodes != null && nodes.length)) return;
|
||||
if (opts.indent) this.indent();
|
||||
const newlineOpts = {
|
||||
addNewlines: opts.addNewlines
|
||||
addNewlines: opts.addNewlines,
|
||||
nextNodeStartLine: 0
|
||||
};
|
||||
const separator = opts.separator ? opts.separator.bind(this) : null;
|
||||
const len = nodes.length;
|
||||
|
||||
for (let i = 0; i < len; i++) {
|
||||
const node = nodes[i];
|
||||
if (!node) continue;
|
||||
if (opts.statement) this._printNewline(true, node, parent, newlineOpts);
|
||||
this.print(node, parent);
|
||||
if (opts.statement) this._printNewline(i === 0, newlineOpts);
|
||||
this.print(node, parent, undefined, opts.trailingCommentsLineOffset || 0);
|
||||
opts.iterator == null ? void 0 : opts.iterator(node, i);
|
||||
if (i < len - 1) separator == null ? void 0 : separator();
|
||||
|
||||
if (opts.iterator) {
|
||||
opts.iterator(node, i);
|
||||
if (opts.statement) {
|
||||
if (i + 1 === len) {
|
||||
this.newline(1);
|
||||
} else {
|
||||
var _nextNode$loc;
|
||||
|
||||
const nextNode = nodes[i + 1];
|
||||
newlineOpts.nextNodeStartLine = ((_nextNode$loc = nextNode.loc) == null ? void 0 : _nextNode$loc.start.line) || 0;
|
||||
|
||||
this._printNewline(true, newlineOpts);
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.separator && i < len - 1) {
|
||||
opts.separator.call(this);
|
||||
}
|
||||
|
||||
if (opts.statement) this._printNewline(false, node, parent, newlineOpts);
|
||||
}
|
||||
|
||||
if (opts.indent) this.dedent();
|
||||
@@ -468,12 +524,20 @@ class Printer {
|
||||
this.print(node, parent);
|
||||
}
|
||||
|
||||
_printTrailingComments(node) {
|
||||
this._printComments(this._getComments(false, node));
|
||||
_printTrailingComments(node, parent, lineOffset) {
|
||||
const comments = this._getComments(false, node);
|
||||
|
||||
if (!(comments != null && comments.length)) return;
|
||||
|
||||
this._printComments(2, comments, node, parent, lineOffset);
|
||||
}
|
||||
|
||||
_printLeadingComments(node) {
|
||||
this._printComments(this._getComments(true, node), true);
|
||||
_printLeadingComments(node, parent) {
|
||||
const comments = this._getComments(true, node);
|
||||
|
||||
if (!(comments != null && comments.length)) return;
|
||||
|
||||
this._printComments(0, comments, node, parent);
|
||||
}
|
||||
|
||||
printInnerComments(node, indent = true) {
|
||||
@@ -482,7 +546,7 @@ class Printer {
|
||||
if (!((_node$innerComments = node.innerComments) != null && _node$innerComments.length)) return;
|
||||
if (indent) this.indent();
|
||||
|
||||
this._printComments(node.innerComments);
|
||||
this._printComments(1, node.innerComments, node);
|
||||
|
||||
if (indent) this.dedent();
|
||||
}
|
||||
@@ -500,7 +564,7 @@ class Printer {
|
||||
return this.printJoin(items, parent, opts);
|
||||
}
|
||||
|
||||
_printNewline(leading, node, parent, opts) {
|
||||
_printNewline(newLine, opts) {
|
||||
if (this.format.retainLines || this.format.compact) return;
|
||||
|
||||
if (this.format.concise) {
|
||||
@@ -508,16 +572,25 @@ class Printer {
|
||||
return;
|
||||
}
|
||||
|
||||
let lines = 0;
|
||||
|
||||
if (this._buf.hasContent()) {
|
||||
if (!leading) lines++;
|
||||
if (opts.addNewlines) lines += opts.addNewlines(leading, node) || 0;
|
||||
const needs = leading ? needsWhitespaceBefore : needsWhitespaceAfter;
|
||||
if (needs(node, parent)) lines++;
|
||||
if (!newLine) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.newline(Math.min(2, lines));
|
||||
const startLine = opts.nextNodeStartLine;
|
||||
const lastCommentLine = this._lastCommentLine;
|
||||
|
||||
if (startLine > 0 && lastCommentLine > 0) {
|
||||
const offset = startLine - lastCommentLine;
|
||||
|
||||
if (offset >= 0) {
|
||||
this.newline(offset || 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this._buf.hasContent()) {
|
||||
this.newline(1);
|
||||
}
|
||||
}
|
||||
|
||||
_getComments(leading, node) {
|
||||
@@ -532,8 +605,12 @@ class Printer {
|
||||
this._printedComments.add(comment);
|
||||
|
||||
const isBlockComment = comment.type === "CommentBlock";
|
||||
const printNewLines = isBlockComment && !skipNewLines && !this._noLineTerminator;
|
||||
if (printNewLines && this._buf.hasContent()) this.newline(1);
|
||||
const printNewLines = isBlockComment && skipNewLines !== 1 && !this._noLineTerminator;
|
||||
|
||||
if (printNewLines && this._buf.hasContent() && skipNewLines !== 2) {
|
||||
this.newline(1);
|
||||
}
|
||||
|
||||
const lastCharCode = this.getLastChar();
|
||||
|
||||
if (lastCharCode !== 91 && lastCharCode !== 123) {
|
||||
@@ -541,7 +618,6 @@ class Printer {
|
||||
}
|
||||
|
||||
let val;
|
||||
let maybeNewline = false;
|
||||
|
||||
if (isBlockComment) {
|
||||
val = `/*${comment.value}*/`;
|
||||
@@ -556,47 +632,127 @@ class Printer {
|
||||
val = val.replace(newlineRegex, "\n");
|
||||
}
|
||||
|
||||
const indentSize = Math.max(this._getIndent(), this.format.retainLines ? 0 : this._buf.getCurrentColumn());
|
||||
let indentSize = this.format.retainLines ? 0 : this._buf.getCurrentColumn();
|
||||
|
||||
if (this._shouldIndent(47) || this.format.retainLines) {
|
||||
indentSize += this._getIndent();
|
||||
}
|
||||
|
||||
val = val.replace(/\n(?!$)/g, `\n${" ".repeat(indentSize)}`);
|
||||
maybeNewline = true;
|
||||
}
|
||||
} else if (!this._noLineTerminator) {
|
||||
val = `//${comment.value}\n`;
|
||||
maybeNewline = true;
|
||||
val = `//${comment.value}`;
|
||||
} else {
|
||||
val = `/*${comment.value}*/`;
|
||||
}
|
||||
|
||||
if (this.endsWith(47)) this._space();
|
||||
this.withSource("start", comment.loc, this._append.bind(this, val, maybeNewline));
|
||||
if (printNewLines) this.newline(1);
|
||||
this.source("start", comment.loc);
|
||||
|
||||
this._append(val, isBlockComment);
|
||||
|
||||
if (!isBlockComment && !this._noLineTerminator) {
|
||||
this.newline(1, true);
|
||||
}
|
||||
|
||||
if (printNewLines && skipNewLines !== 3) {
|
||||
this.newline(1);
|
||||
}
|
||||
}
|
||||
|
||||
_printComments(comments, inlinePureAnnotation) {
|
||||
if (!(comments != null && comments.length)) return;
|
||||
_printComments(type, comments, node, parent, lineOffset = 0) {
|
||||
{
|
||||
const nodeLoc = node.loc;
|
||||
const len = comments.length;
|
||||
let hasLoc = !!nodeLoc;
|
||||
const nodeStartLine = hasLoc ? nodeLoc.start.line : 0;
|
||||
const nodeEndLine = hasLoc ? nodeLoc.end.line : 0;
|
||||
let lastLine = 0;
|
||||
let leadingCommentNewline = 0;
|
||||
|
||||
if (inlinePureAnnotation && comments.length === 1 && PURE_ANNOTATION_RE.test(comments[0].value)) {
|
||||
this._printComment(comments[0], this._buf.hasContent() && !this.endsWith(10));
|
||||
} else {
|
||||
for (const comment of comments) {
|
||||
this._printComment(comment);
|
||||
for (let i = 0; i < len; i++) {
|
||||
const comment = comments[i];
|
||||
|
||||
if (hasLoc && comment.loc && !this._printedComments.has(comment)) {
|
||||
const commentStartLine = comment.loc.start.line;
|
||||
const commentEndLine = comment.loc.end.line;
|
||||
|
||||
if (type === 0) {
|
||||
let offset = 0;
|
||||
|
||||
if (i === 0) {
|
||||
if (this._buf.hasContent() && (comment.type === "CommentLine" || commentStartLine != commentEndLine)) {
|
||||
offset = leadingCommentNewline = 1;
|
||||
}
|
||||
} else {
|
||||
offset = commentStartLine - lastLine;
|
||||
}
|
||||
|
||||
lastLine = commentEndLine;
|
||||
this.newline(offset);
|
||||
|
||||
this._printComment(comment, 1);
|
||||
|
||||
if (i + 1 === len) {
|
||||
this.newline(Math.max(nodeStartLine - lastLine, leadingCommentNewline));
|
||||
lastLine = nodeStartLine;
|
||||
}
|
||||
} else if (type === 1) {
|
||||
const offset = commentStartLine - (i === 0 ? nodeStartLine : lastLine);
|
||||
lastLine = commentEndLine;
|
||||
this.newline(offset);
|
||||
|
||||
this._printComment(comment, 1);
|
||||
|
||||
if (i + 1 === len) {
|
||||
this.newline(Math.min(1, nodeEndLine - lastLine));
|
||||
lastLine = nodeEndLine;
|
||||
}
|
||||
} else {
|
||||
const offset = commentStartLine - (i === 0 ? nodeEndLine - lineOffset : lastLine);
|
||||
lastLine = commentEndLine;
|
||||
this.newline(offset);
|
||||
|
||||
this._printComment(comment, 1);
|
||||
}
|
||||
} else {
|
||||
hasLoc = false;
|
||||
|
||||
if (len === 1) {
|
||||
const singleLine = comment.loc ? comment.loc.start.line === comment.loc.end.line : !comment.value.includes("\n");
|
||||
const shouldSkipNewline = singleLine && !isStatement(node) && !isClassBody(parent) && !isTSInterfaceBody(parent);
|
||||
|
||||
if (type === 0) {
|
||||
this._printComment(comment, shouldSkipNewline && node.type !== "ObjectExpression" || singleLine && isFunction(parent, {
|
||||
body: node
|
||||
}) ? 1 : 0);
|
||||
} else if (shouldSkipNewline && type === 2) {
|
||||
this._printComment(comment, 1);
|
||||
} else {
|
||||
this._printComment(comment, 0);
|
||||
}
|
||||
} else if (type === 1 && !(node.type === "ObjectExpression" && node.properties.length > 1) && node.type !== "ClassBody" && node.type !== "TSInterfaceBody") {
|
||||
this._printComment(comment, i === 0 ? 2 : i === len - 1 ? 3 : 0);
|
||||
} else {
|
||||
this._printComment(comment, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type === 2 && hasLoc && lastLine) {
|
||||
this._lastCommentLine = lastLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printAssertions(node) {
|
||||
var _node$assertions;
|
||||
|
||||
if ((_node$assertions = node.assertions) != null && _node$assertions.length) {
|
||||
this.space();
|
||||
this.word("assert");
|
||||
this.space();
|
||||
this.tokenChar(123);
|
||||
this.space();
|
||||
this.printList(node.assertions, node);
|
||||
this.space();
|
||||
this.tokenChar(125);
|
||||
}
|
||||
this.space();
|
||||
this.printInnerComments(node);
|
||||
this.tokenChar(123);
|
||||
this.space();
|
||||
this.printList(node.assertions, node);
|
||||
this.space();
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/generator",
|
||||
"version": "7.19.3",
|
||||
"version": "7.20.0",
|
||||
"description": "Turns an AST into code.",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"license": "MIT",
|
||||
@@ -19,13 +19,13 @@
|
||||
"lib"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.19.3",
|
||||
"@babel/types": "^7.20.0",
|
||||
"@jridgewell/gen-mapping": "^0.3.2",
|
||||
"jsesc": "^2.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-fixtures": "^7.18.6",
|
||||
"@babel/parser": "^7.19.3",
|
||||
"@babel/helper-fixtures": "^7.19.4",
|
||||
"@babel/parser": "^7.20.0",
|
||||
"@jridgewell/trace-mapping": "^0.3.8",
|
||||
"@types/jsesc": "^2.5.0",
|
||||
"charcodes": "^0.2.0"
|
||||
|
||||
Generated
Vendored
+1
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.TargetNames = void 0;
|
||||
const TargetNames = {
|
||||
node: "node",
|
||||
deno: "deno",
|
||||
chrome: "chrome",
|
||||
opera: "opera",
|
||||
edge: "edge",
|
||||
|
||||
Generated
Vendored
+1
@@ -19,6 +19,7 @@ const browserNameMap = {
|
||||
ie_mob: "ie",
|
||||
ios_saf: "ios",
|
||||
node: "node",
|
||||
deno: "deno",
|
||||
op_mob: "opera",
|
||||
opera: "opera",
|
||||
safari: "safari",
|
||||
|
||||
Generated
Vendored
+3
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-compilation-targets",
|
||||
"version": "7.19.3",
|
||||
"version": "7.20.0",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"license": "MIT",
|
||||
"description": "Helper functions on Babel compilation targets",
|
||||
@@ -22,7 +22,7 @@
|
||||
"babel-plugin"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/compat-data": "^7.19.3",
|
||||
"@babel/compat-data": "^7.20.0",
|
||||
"@babel/helper-validator-option": "^7.18.6",
|
||||
"browserslist": "^4.21.3",
|
||||
"semver": "^6.3.0"
|
||||
@@ -31,7 +31,7 @@
|
||||
"@babel/core": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.19.3",
|
||||
"@babel/core": "^7.19.6",
|
||||
"@babel/helper-plugin-test-runner": "^7.18.6",
|
||||
"@types/semver": "^5.5.0"
|
||||
},
|
||||
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getDynamicImportSource = getDynamicImportSource;
|
||||
|
||||
var t = require("@babel/types");
|
||||
|
||||
var _template = require("@babel/template");
|
||||
|
||||
function getDynamicImportSource(node) {
|
||||
const [source] = node.arguments;
|
||||
return t.isStringLiteral(source) || t.isTemplateLiteral(source) ? source : _template.default.expression.ast`\`\${${source}}\``;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=dynamic-import.js.map
|
||||
Generated
Vendored
+8
@@ -5,6 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
exports.buildNamespaceInitStatements = buildNamespaceInitStatements;
|
||||
exports.ensureStatementsHoisted = ensureStatementsHoisted;
|
||||
Object.defineProperty(exports, "getDynamicImportSource", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _dynamicImport.getDynamicImportSource;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "getModuleName", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
@@ -52,6 +58,8 @@ var _rewriteLiveReferences = require("./rewrite-live-references");
|
||||
|
||||
var _normalizeAndLoadMetadata = require("./normalize-and-load-metadata");
|
||||
|
||||
var _dynamicImport = require("./dynamic-import");
|
||||
|
||||
var _getModuleName = require("./get-module-name");
|
||||
|
||||
const {
|
||||
|
||||
Generated
Vendored
+5
-5
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-module-transforms",
|
||||
"version": "7.19.0",
|
||||
"version": "7.19.6",
|
||||
"description": "Babel helper functions for implementing ES6 module transformations",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-helper-module-transforms",
|
||||
@@ -17,12 +17,12 @@
|
||||
"dependencies": {
|
||||
"@babel/helper-environment-visitor": "^7.18.9",
|
||||
"@babel/helper-module-imports": "^7.18.6",
|
||||
"@babel/helper-simple-access": "^7.18.6",
|
||||
"@babel/helper-simple-access": "^7.19.4",
|
||||
"@babel/helper-split-export-declaration": "^7.18.6",
|
||||
"@babel/helper-validator-identifier": "^7.18.6",
|
||||
"@babel/helper-validator-identifier": "^7.19.1",
|
||||
"@babel/template": "^7.18.10",
|
||||
"@babel/traverse": "^7.19.0",
|
||||
"@babel/types": "^7.19.0"
|
||||
"@babel/traverse": "^7.19.6",
|
||||
"@babel/types": "^7.19.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
|
||||
+3
-1
@@ -97,4 +97,6 @@ const simpleAssignmentVisitor = {
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
+4
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-simple-access",
|
||||
"version": "7.18.6",
|
||||
"version": "7.19.4",
|
||||
"description": "Babel helper for ensuring that access to a given value is performed through simple accesses",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-helper-simple-access",
|
||||
@@ -15,10 +15,11 @@
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.18.6"
|
||||
"@babel/types": "^7.19.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/traverse": "^7.18.6"
|
||||
"@babel/core": "^7.19.3",
|
||||
"@babel/traverse": "^7.19.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
|
||||
+36
-17
@@ -27,7 +27,7 @@ function readStringContents(type, input, pos, lineStart, curLine, errors) {
|
||||
const initialLineStart = lineStart;
|
||||
const initialCurLine = curLine;
|
||||
let out = "";
|
||||
let containsInvalid = false;
|
||||
let firstInvalidLoc = null;
|
||||
let chunkStart = pos;
|
||||
const {
|
||||
length
|
||||
@@ -49,20 +49,23 @@ function readStringContents(type, input, pos, lineStart, curLine, errors) {
|
||||
|
||||
if (ch === 92) {
|
||||
out += input.slice(chunkStart, pos);
|
||||
let escaped;
|
||||
const res = readEscapedChar(input, pos, lineStart, curLine, type === "template", errors);
|
||||
|
||||
if (res.ch === null && !firstInvalidLoc) {
|
||||
firstInvalidLoc = {
|
||||
pos,
|
||||
lineStart,
|
||||
curLine
|
||||
};
|
||||
} else {
|
||||
out += res.ch;
|
||||
}
|
||||
|
||||
({
|
||||
ch: escaped,
|
||||
pos,
|
||||
lineStart,
|
||||
curLine
|
||||
} = readEscapedChar(input, pos, lineStart, curLine, type === "template", errors));
|
||||
|
||||
if (escaped === null) {
|
||||
containsInvalid = true;
|
||||
} else {
|
||||
out += escaped;
|
||||
}
|
||||
|
||||
} = res);
|
||||
chunkStart = pos;
|
||||
} else if (ch === 8232 || ch === 8233) {
|
||||
++pos;
|
||||
@@ -90,9 +93,10 @@ function readStringContents(type, input, pos, lineStart, curLine, errors) {
|
||||
return {
|
||||
pos,
|
||||
str: out,
|
||||
containsInvalid,
|
||||
firstInvalidLoc,
|
||||
lineStart,
|
||||
curLine
|
||||
curLine,
|
||||
containsInvalid: !!firstInvalidLoc
|
||||
};
|
||||
}
|
||||
|
||||
@@ -213,7 +217,7 @@ function readHexChar(input, pos, lineStart, curLine, len, forceLen, throwOnInval
|
||||
({
|
||||
n,
|
||||
pos
|
||||
} = readInt(input, pos, lineStart, curLine, 16, len, forceLen, false, errors));
|
||||
} = readInt(input, pos, lineStart, curLine, 16, len, forceLen, false, errors, !throwOnInvalid));
|
||||
|
||||
if (n === null) {
|
||||
if (throwOnInvalid) {
|
||||
@@ -229,7 +233,7 @@ function readHexChar(input, pos, lineStart, curLine, len, forceLen, throwOnInval
|
||||
};
|
||||
}
|
||||
|
||||
function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumSeparator, errors) {
|
||||
function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumSeparator, errors, bailOnError) {
|
||||
const start = pos;
|
||||
const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct;
|
||||
const isAllowedSibling = radix === 16 ? isAllowedNumericSeparatorSibling.hex : radix === 10 ? isAllowedNumericSeparatorSibling.dec : radix === 8 ? isAllowedNumericSeparatorSibling.oct : isAllowedNumericSeparatorSibling.bin;
|
||||
@@ -245,8 +249,16 @@ function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumS
|
||||
const next = input.charCodeAt(pos + 1);
|
||||
|
||||
if (!allowNumSeparator) {
|
||||
if (bailOnError) return {
|
||||
n: null,
|
||||
pos
|
||||
};
|
||||
errors.numericSeparatorInEscapeSequence(pos, lineStart, curLine);
|
||||
} else if (Number.isNaN(next) || !isAllowedSibling(next) || forbiddenSiblings.has(prev) || forbiddenSiblings.has(next)) {
|
||||
if (bailOnError) return {
|
||||
n: null,
|
||||
pos
|
||||
};
|
||||
errors.unexpectedNumericSeparator(pos, lineStart, curLine);
|
||||
}
|
||||
|
||||
@@ -265,7 +277,12 @@ function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumS
|
||||
}
|
||||
|
||||
if (val >= radix) {
|
||||
if (val <= 9 && errors.invalidDigit(pos, lineStart, curLine, radix)) {
|
||||
if (val <= 9 && bailOnError) {
|
||||
return {
|
||||
n: null,
|
||||
pos
|
||||
};
|
||||
} else if (val <= 9 && errors.invalidDigit(pos, lineStart, curLine, radix)) {
|
||||
val = 0;
|
||||
} else if (forceLen) {
|
||||
val = 0;
|
||||
@@ -325,4 +342,6 @@ function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) {
|
||||
code,
|
||||
pos
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-string-parser",
|
||||
"version": "7.18.10",
|
||||
"version": "7.19.4",
|
||||
"description": "A utility package to parse strings",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ var _default = Object.freeze({
|
||||
awaitAsyncGenerator: helper("7.0.0-beta.0", 'import OverloadYield from"OverloadYield";export default function _awaitAsyncGenerator(value){return new OverloadYield(value,0)}'),
|
||||
jsx: helper("7.0.0-beta.0", 'var REACT_ELEMENT_TYPE;export default function _createRawReactElement(type,props,key,children){REACT_ELEMENT_TYPE||(REACT_ELEMENT_TYPE="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103);var defaultProps=type&&type.defaultProps,childrenLength=arguments.length-3;if(props||0===childrenLength||(props={children:void 0}),1===childrenLength)props.children=children;else if(childrenLength>1){for(var childArray=new Array(childrenLength),i=0;i<childrenLength;i++)childArray[i]=arguments[i+3];props.children=childArray}if(props&&defaultProps)for(var propName in defaultProps)void 0===props[propName]&&(props[propName]=defaultProps[propName]);else props||(props=defaultProps||{});return{$$typeof:REACT_ELEMENT_TYPE,type:type,key:void 0===key?null:""+key,ref:null,props:props,_owner:null}}'),
|
||||
objectSpread2: helper("7.5.0", 'import defineProperty from"defineProperty";function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter((function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable}))),keys.push.apply(keys,symbols)}return keys}export default function _objectSpread2(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach((function(key){defineProperty(target,key,source[key])})):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach((function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))}))}return target}'),
|
||||
regeneratorRuntime: helper("7.18.0", 'export default function _regeneratorRuntime(){"use strict";\n/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_regeneratorRuntime=function(){return exports};var exports={},Op=Object.prototype,hasOwn=Op.hasOwnProperty,$Symbol="function"==typeof Symbol?Symbol:{},iteratorSymbol=$Symbol.iterator||"@@iterator",asyncIteratorSymbol=$Symbol.asyncIterator||"@@asyncIterator",toStringTagSymbol=$Symbol.toStringTag||"@@toStringTag";function define(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}),obj[key]}try{define({},"")}catch(err){define=function(obj,key,value){return obj[key]=value}}function wrap(innerFn,outerFn,self,tryLocsList){var protoGenerator=outerFn&&outerFn.prototype instanceof Generator?outerFn:Generator,generator=Object.create(protoGenerator.prototype),context=new Context(tryLocsList||[]);return generator._invoke=function(innerFn,self,context){var state="suspendedStart";return function(method,arg){if("executing"===state)throw new Error("Generator is already running");if("completed"===state){if("throw"===method)throw arg;return doneResult()}for(context.method=method,context.arg=arg;;){var delegate=context.delegate;if(delegate){var delegateResult=maybeInvokeDelegate(delegate,context);if(delegateResult){if(delegateResult===ContinueSentinel)continue;return delegateResult}}if("next"===context.method)context.sent=context._sent=context.arg;else if("throw"===context.method){if("suspendedStart"===state)throw state="completed",context.arg;context.dispatchException(context.arg)}else"return"===context.method&&context.abrupt("return",context.arg);state="executing";var record=tryCatch(innerFn,self,context);if("normal"===record.type){if(state=context.done?"completed":"suspendedYield",record.arg===ContinueSentinel)continue;return{value:record.arg,done:context.done}}"throw"===record.type&&(state="completed",context.method="throw",context.arg=record.arg)}}}(innerFn,self,context),generator}function tryCatch(fn,obj,arg){try{return{type:"normal",arg:fn.call(obj,arg)}}catch(err){return{type:"throw",arg:err}}}exports.wrap=wrap;var ContinueSentinel={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var IteratorPrototype={};define(IteratorPrototype,iteratorSymbol,(function(){return this}));var getProto=Object.getPrototypeOf,NativeIteratorPrototype=getProto&&getProto(getProto(values([])));NativeIteratorPrototype&&NativeIteratorPrototype!==Op&&hasOwn.call(NativeIteratorPrototype,iteratorSymbol)&&(IteratorPrototype=NativeIteratorPrototype);var Gp=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(IteratorPrototype);function defineIteratorMethods(prototype){["next","throw","return"].forEach((function(method){define(prototype,method,(function(arg){return this._invoke(method,arg)}))}))}function AsyncIterator(generator,PromiseImpl){function invoke(method,arg,resolve,reject){var record=tryCatch(generator[method],generator,arg);if("throw"!==record.type){var result=record.arg,value=result.value;return value&&"object"==typeof value&&hasOwn.call(value,"__await")?PromiseImpl.resolve(value.__await).then((function(value){invoke("next",value,resolve,reject)}),(function(err){invoke("throw",err,resolve,reject)})):PromiseImpl.resolve(value).then((function(unwrapped){result.value=unwrapped,resolve(result)}),(function(error){return invoke("throw",error,resolve,reject)}))}reject(record.arg)}var previousPromise;this._invoke=function(method,arg){function callInvokeWithMethodAndArg(){return new PromiseImpl((function(resolve,reject){invoke(method,arg,resolve,reject)}))}return previousPromise=previousPromise?previousPromise.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(delegate,context){var method=delegate.iterator[context.method];if(undefined===method){if(context.delegate=null,"throw"===context.method){if(delegate.iterator.return&&(context.method="return",context.arg=undefined,maybeInvokeDelegate(delegate,context),"throw"===context.method))return ContinueSentinel;context.method="throw",context.arg=new TypeError("The iterator does not provide a \'throw\' method")}return ContinueSentinel}var record=tryCatch(method,delegate.iterator,context.arg);if("throw"===record.type)return context.method="throw",context.arg=record.arg,context.delegate=null,ContinueSentinel;var info=record.arg;return info?info.done?(context[delegate.resultName]=info.value,context.next=delegate.nextLoc,"return"!==context.method&&(context.method="next",context.arg=undefined),context.delegate=null,ContinueSentinel):info:(context.method="throw",context.arg=new TypeError("iterator result is not an object"),context.delegate=null,ContinueSentinel)}function pushTryEntry(locs){var entry={tryLoc:locs[0]};1 in locs&&(entry.catchLoc=locs[1]),2 in locs&&(entry.finallyLoc=loLine truncated
|
||||
regeneratorRuntime: helper("7.18.0", 'export default function _regeneratorRuntime(){"use strict";\n/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_regeneratorRuntime=function(){return exports};var exports={},Op=Object.prototype,hasOwn=Op.hasOwnProperty,defineProperty=Object.defineProperty||function(obj,key,desc){obj[key]=desc.value},$Symbol="function"==typeof Symbol?Symbol:{},iteratorSymbol=$Symbol.iterator||"@@iterator",asyncIteratorSymbol=$Symbol.asyncIterator||"@@asyncIterator",toStringTagSymbol=$Symbol.toStringTag||"@@toStringTag";function define(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}),obj[key]}try{define({},"")}catch(err){define=function(obj,key,value){return obj[key]=value}}function wrap(innerFn,outerFn,self,tryLocsList){var protoGenerator=outerFn&&outerFn.prototype instanceof Generator?outerFn:Generator,generator=Object.create(protoGenerator.prototype),context=new Context(tryLocsList||[]);return defineProperty(generator,"_invoke",{value:makeInvokeMethod(innerFn,self,context)}),generator}function tryCatch(fn,obj,arg){try{return{type:"normal",arg:fn.call(obj,arg)}}catch(err){return{type:"throw",arg:err}}}exports.wrap=wrap;var ContinueSentinel={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var IteratorPrototype={};define(IteratorPrototype,iteratorSymbol,(function(){return this}));var getProto=Object.getPrototypeOf,NativeIteratorPrototype=getProto&&getProto(getProto(values([])));NativeIteratorPrototype&&NativeIteratorPrototype!==Op&&hasOwn.call(NativeIteratorPrototype,iteratorSymbol)&&(IteratorPrototype=NativeIteratorPrototype);var Gp=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(IteratorPrototype);function defineIteratorMethods(prototype){["next","throw","return"].forEach((function(method){define(prototype,method,(function(arg){return this._invoke(method,arg)}))}))}function AsyncIterator(generator,PromiseImpl){function invoke(method,arg,resolve,reject){var record=tryCatch(generator[method],generator,arg);if("throw"!==record.type){var result=record.arg,value=result.value;return value&&"object"==typeof value&&hasOwn.call(value,"__await")?PromiseImpl.resolve(value.__await).then((function(value){invoke("next",value,resolve,reject)}),(function(err){invoke("throw",err,resolve,reject)})):PromiseImpl.resolve(value).then((function(unwrapped){result.value=unwrapped,resolve(result)}),(function(error){return invoke("throw",error,resolve,reject)}))}reject(record.arg)}var previousPromise;defineProperty(this,"_invoke",{value:function(method,arg){function callInvokeWithMethodAndArg(){return new PromiseImpl((function(resolve,reject){invoke(method,arg,resolve,reject)}))}return previousPromise=previousPromise?previousPromise.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}})}function makeInvokeMethod(innerFn,self,context){var state="suspendedStart";return function(method,arg){if("executing"===state)throw new Error("Generator is already running");if("completed"===state){if("throw"===method)throw arg;return doneResult()}for(context.method=method,context.arg=arg;;){var delegate=context.delegate;if(delegate){var delegateResult=maybeInvokeDelegate(delegate,context);if(delegateResult){if(delegateResult===ContinueSentinel)continue;return delegateResult}}if("next"===context.method)context.sent=context._sent=context.arg;else if("throw"===context.method){if("suspendedStart"===state)throw state="completed",context.arg;context.dispatchException(context.arg)}else"return"===context.method&&context.abrupt("return",context.arg);state="executing";var record=tryCatch(innerFn,self,context);if("normal"===record.type){if(state=context.done?"completed":"suspendedYield",record.arg===ContinueSentinel)continue;return{value:record.arg,done:context.done}}"throw"===record.type&&(state="completed",context.method="throw",context.arg=record.arg)}}}function maybeInvokeDelegate(delegate,context){var method=delegate.iterator[context.method];if(undefined===method){if(context.delegate=null,"throw"===context.method){if(delegate.iterator.return&&(context.method="return",context.arg=undefined,maybeInvokeDelegate(delegate,context),"throw"===context.method))return ContinueSentinel;context.method="throw",context.arg=new TypeError("The iterator does not provide a \'throw\' method")}return ContinueSentinel}var record=tryCatch(method,delegate.iterator,context.arg);if("throw"===record.type)return context.method="throw",context.arg=record.arg,context.delegate=null,ContinueSentinel;var info=record.arg;return info?info.done?(context[delegate.resultName]=info.value,context.next=delegate.nextLoc,"return"!==context.method&&(context.method="next",context.arg=undefined),context.delegate=null,ContinueSentinel):info:(context.method="throw",context.arg=new TypeError("iterator result is not an objeLine truncated
|
||||
typeof: helper("7.0.0-beta.0", 'export default function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_typeof(obj)}'),
|
||||
wrapRegExp: helper("7.19.0", 'import setPrototypeOf from"setPrototypeOf";import inherits from"inherits";export default function _wrapRegExp(){_wrapRegExp=function(re,groups){return new BabelRegExp(re,void 0,groups)};var _super=RegExp.prototype,_groups=new WeakMap;function BabelRegExp(re,flags,groups){var _this=new RegExp(re,flags);return _groups.set(_this,groups||_groups.get(re)),setPrototypeOf(_this,BabelRegExp.prototype)}function buildGroups(result,re){var g=_groups.get(re);return Object.keys(g).reduce((function(groups,name){var i=g[name];if("number"==typeof i)groups[name]=result[i];else{for(var k=0;void 0===result[i[k]]&&k+1<i.length;)k++;groups[name]=result[i[k]]}return groups}),Object.create(null))}return inherits(BabelRegExp,RegExp),BabelRegExp.prototype.exec=function(str){var result=_super.exec.call(this,str);return result&&(result.groups=buildGroups(result,this)),result},BabelRegExp.prototype[Symbol.replace]=function(str,substitution){if("string"==typeof substitution){var groups=_groups.get(this);return _super[Symbol.replace].call(this,str,substitution.replace(/\\$<([^>]+)>/g,(function(_,name){return"$"+groups[name]})))}if("function"==typeof substitution){var _this=this;return _super[Symbol.replace].call(this,str,(function(){var args=arguments;return"object"!=typeof args[args.length-1]&&(args=[].slice.call(args)).push(buildGroups(args,_this)),substitution.apply(this,args)}))}return _super[Symbol.replace].call(this,str,substitution)},_wrapRegExp.apply(this,arguments)}')
|
||||
});
|
||||
|
||||
+1
-1
@@ -402,7 +402,7 @@ helpers.newArrowCheck = helper("7.0.0-beta.0")`
|
||||
`;
|
||||
helpers.objectDestructuringEmpty = helper("7.0.0-beta.0")`
|
||||
export default function _objectDestructuringEmpty(obj) {
|
||||
if (obj == null) throw new TypeError("Cannot destructure undefined");
|
||||
if (obj == null) throw new TypeError("Cannot destructure " + obj);
|
||||
}
|
||||
`;
|
||||
helpers.objectWithoutPropertiesLoose = helper("7.0.0-beta.0")`
|
||||
|
||||
Generated
Vendored
+21
-5
@@ -15,6 +15,11 @@ function _regeneratorRuntime() {
|
||||
var _exports = {};
|
||||
var Op = Object.prototype;
|
||||
var hasOwn = Op.hasOwnProperty;
|
||||
|
||||
var defineProperty = Object.defineProperty || function (obj, key, desc) {
|
||||
obj[key] = desc.value;
|
||||
};
|
||||
|
||||
var undefined;
|
||||
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
||||
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
||||
@@ -43,7 +48,9 @@ function _regeneratorRuntime() {
|
||||
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
||||
var generator = Object.create(protoGenerator.prototype);
|
||||
var context = new Context(tryLocsList || []);
|
||||
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
||||
defineProperty(generator, "_invoke", {
|
||||
value: makeInvokeMethod(innerFn, self, context)
|
||||
});
|
||||
return generator;
|
||||
}
|
||||
|
||||
@@ -88,8 +95,14 @@ function _regeneratorRuntime() {
|
||||
|
||||
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
||||
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
||||
define(Gp, "constructor", GeneratorFunctionPrototype);
|
||||
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
||||
defineProperty(Gp, "constructor", {
|
||||
value: GeneratorFunctionPrototype,
|
||||
configurable: true
|
||||
});
|
||||
defineProperty(GeneratorFunctionPrototype, "constructor", {
|
||||
value: GeneratorFunction,
|
||||
configurable: true
|
||||
});
|
||||
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
||||
|
||||
function defineIteratorMethods(prototype) {
|
||||
@@ -162,7 +175,9 @@ function _regeneratorRuntime() {
|
||||
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
||||
}
|
||||
|
||||
this._invoke = enqueue;
|
||||
defineProperty(this, "_invoke", {
|
||||
value: enqueue
|
||||
});
|
||||
}
|
||||
|
||||
defineIteratorMethods(AsyncIterator.prototype);
|
||||
@@ -344,7 +359,8 @@ function _regeneratorRuntime() {
|
||||
this.reset(true);
|
||||
}
|
||||
|
||||
_exports.keys = function (object) {
|
||||
_exports.keys = function (val) {
|
||||
var object = Object(val);
|
||||
var keys = [];
|
||||
|
||||
for (var key in object) {
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helpers",
|
||||
"version": "7.19.0",
|
||||
"version": "7.20.0",
|
||||
"description": "Collection of helper functions used by Babel transforms.",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-helpers",
|
||||
@@ -16,14 +16,14 @@
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/template": "^7.18.10",
|
||||
"@babel/traverse": "^7.19.0",
|
||||
"@babel/types": "^7.19.0"
|
||||
"@babel/traverse": "^7.20.0",
|
||||
"@babel/types": "^7.20.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/generator": "^7.19.0",
|
||||
"@babel/generator": "^7.20.0",
|
||||
"@babel/helper-plugin-test-runner": "^7.18.6",
|
||||
"@babel/parser": "^7.19.0",
|
||||
"regenerator-runtime": "^0.13.9",
|
||||
"@babel/parser": "^7.20.0",
|
||||
"regenerator-runtime": "^0.13.10",
|
||||
"terser": "^5.9.0"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
+696
-553
File diff suppressed because it is too large.
Load diff
+3
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/parser",
|
||||
"version": "7.19.3",
|
||||
"version": "7.20.0",
|
||||
"description": "A JavaScript parser",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-parser",
|
||||
@@ -36,8 +36,8 @@
|
||||
"devDependencies": {
|
||||
"@babel/code-frame": "^7.18.6",
|
||||
"@babel/helper-check-duplicate-nodes": "^7.18.6",
|
||||
"@babel/helper-fixtures": "^7.18.6",
|
||||
"@babel/helper-string-parser": "^7.18.10",
|
||||
"@babel/helper-fixtures": "^7.19.4",
|
||||
"@babel/helper-string-parser": "^7.19.4",
|
||||
"@babel/helper-validator-identifier": "^7.19.1",
|
||||
"charcodes": "^0.2.0"
|
||||
},
|
||||
|
||||
Generated
Vendored
+3
-1
@@ -19,4 +19,6 @@ var _default = (0, _helperPluginUtils.declare)(api => {
|
||||
};
|
||||
});
|
||||
|
||||
exports.default = _default;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
Generated
Vendored
+3
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/plugin-syntax-import-assertions",
|
||||
"version": "7.18.6",
|
||||
"version": "7.20.0",
|
||||
"description": "Allow parsing of the module assertion attributes in the import statement",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -16,13 +16,13 @@
|
||||
"babel-plugin"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.18.6"
|
||||
"@babel/helper-plugin-utils": "^7.19.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.18.6"
|
||||
"@babel/core": "^7.19.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
|
||||
+6
@@ -265,6 +265,9 @@ function hoistFunctionEnvironment(fnPath, noNewArrows = true, allowInsertArrow =
|
||||
const isCall = superParentPath.isCallExpression({
|
||||
callee: superProp.node
|
||||
});
|
||||
const isTaggedTemplate = superParentPath.isTaggedTemplateExpression({
|
||||
tag: superProp.node
|
||||
});
|
||||
const superBinding = getSuperPropBinding(thisEnvFn, isAssignment, key);
|
||||
const args = [];
|
||||
|
||||
@@ -285,6 +288,9 @@ function hoistFunctionEnvironment(fnPath, noNewArrows = true, allowInsertArrow =
|
||||
thisPaths.push(superParentPath.get("arguments.0"));
|
||||
} else if (isAssignment) {
|
||||
superParentPath.replaceWith(call);
|
||||
} else if (isTaggedTemplate) {
|
||||
superProp.replaceWith(callExpression(memberExpression(call, identifier("bind"), false), [thisExpression()]));
|
||||
thisPaths.push(superProp.get("arguments.0"));
|
||||
} else {
|
||||
superProp.replaceWith(call);
|
||||
}
|
||||
|
||||
+25
@@ -25,6 +25,13 @@ class Binding {
|
||||
this.scope = scope;
|
||||
this.path = path;
|
||||
this.kind = kind;
|
||||
|
||||
if ((kind === "var" || kind === "hoisted") && isDeclaredInLoop(path || (() => {
|
||||
throw new Error("Internal Babel error: unreachable ");
|
||||
})())) {
|
||||
this.reassign(path);
|
||||
}
|
||||
|
||||
this.clearValue();
|
||||
}
|
||||
|
||||
@@ -74,4 +81,22 @@ class Binding {
|
||||
|
||||
exports.default = Binding;
|
||||
|
||||
function isDeclaredInLoop(path) {
|
||||
for (let {
|
||||
parentPath,
|
||||
key
|
||||
} = path; parentPath; ({
|
||||
parentPath,
|
||||
key
|
||||
} = parentPath)) {
|
||||
if (parentPath.isFunctionParent()) return false;
|
||||
|
||||
if (parentPath.isWhile() || parentPath.isForXStatement() || parentPath.isForStatement() && key === "body") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=binding.js.map
|
||||
+4
-1
@@ -578,9 +578,12 @@ class Scope {
|
||||
this.registerBinding("hoisted", path.get("id"), path);
|
||||
} else if (path.isVariableDeclaration()) {
|
||||
const declarations = path.get("declarations");
|
||||
const {
|
||||
kind
|
||||
} = path.node;
|
||||
|
||||
for (const declar of declarations) {
|
||||
this.registerBinding(path.node.kind, declar);
|
||||
this.registerBinding(kind === "using" ? "const" : kind, declar);
|
||||
}
|
||||
} else if (path.isClassDeclaration()) {
|
||||
if (path.node.declare) return;
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/traverse",
|
||||
"version": "7.19.3",
|
||||
"version": "7.20.0",
|
||||
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-traverse",
|
||||
@@ -17,13 +17,13 @@
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.18.6",
|
||||
"@babel/generator": "^7.19.3",
|
||||
"@babel/generator": "^7.20.0",
|
||||
"@babel/helper-environment-visitor": "^7.18.9",
|
||||
"@babel/helper-function-name": "^7.19.0",
|
||||
"@babel/helper-hoist-variables": "^7.18.6",
|
||||
"@babel/helper-split-export-declaration": "^7.18.6",
|
||||
"@babel/parser": "^7.19.3",
|
||||
"@babel/types": "^7.19.3",
|
||||
"@babel/parser": "^7.20.0",
|
||||
"@babel/types": "^7.20.0",
|
||||
"debug": "^4.1.0",
|
||||
"globals": "^11.1.0"
|
||||
},
|
||||
|
||||
Generated
Vendored
-25
@@ -1,25 +0,0 @@
|
||||
import * as t from "@babel/types";
|
||||
|
||||
export default function generateAsserts() {
|
||||
let output = `/*
|
||||
* This file is auto-generated! Do not modify it directly.
|
||||
* To re-generate run 'make build'
|
||||
*/
|
||||
import type * as t from "@babel/types";
|
||||
import type NodePath from "../index";
|
||||
|
||||
|
||||
export interface NodePathAssetions {`;
|
||||
|
||||
for (const type of [...t.TYPES].sort()) {
|
||||
output += `
|
||||
assert${type}(
|
||||
opts?: object,
|
||||
): asserts this is NodePath<t.${type}>;`;
|
||||
}
|
||||
|
||||
output += `
|
||||
}`;
|
||||
|
||||
return output;
|
||||
}
|
||||
Generated
Vendored
-27
@@ -1,27 +0,0 @@
|
||||
import * as t from "@babel/types";
|
||||
|
||||
export default function generateValidators() {
|
||||
let output = `/*
|
||||
* This file is auto-generated! Do not modify it directly.
|
||||
* To re-generate run 'make build'
|
||||
*/
|
||||
import type * as t from "@babel/types";
|
||||
import type NodePath from "../index";
|
||||
import type { VirtualTypeNodePathValidators } from "../lib/virtual-types-validator";
|
||||
|
||||
interface BaseNodePathValidators {
|
||||
`;
|
||||
|
||||
for (const type of [...t.TYPES].sort()) {
|
||||
output += `is${type}<T extends t.Node>(this: NodePath<T>, opts?: object): this is NodePath<T & t.${type}>;`;
|
||||
}
|
||||
|
||||
output += `
|
||||
}
|
||||
|
||||
export interface NodePathValidators
|
||||
extends BaseNodePathValidators, VirtualTypeNodePathValidators {}
|
||||
`;
|
||||
|
||||
return output;
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
{ "type": "module" }
|
||||
Generated
Vendored
+5
@@ -250,6 +250,7 @@ exports.assertTSParenthesizedType = assertTSParenthesizedType;
|
||||
exports.assertTSPropertySignature = assertTSPropertySignature;
|
||||
exports.assertTSQualifiedName = assertTSQualifiedName;
|
||||
exports.assertTSRestType = assertTSRestType;
|
||||
exports.assertTSSatisfiesExpression = assertTSSatisfiesExpression;
|
||||
exports.assertTSStringKeyword = assertTSStringKeyword;
|
||||
exports.assertTSSymbolKeyword = assertTSSymbolKeyword;
|
||||
exports.assertTSThisType = assertTSThisType;
|
||||
@@ -1245,6 +1246,10 @@ function assertTSAsExpression(node, opts) {
|
||||
assert("TSAsExpression", node, opts);
|
||||
}
|
||||
|
||||
function assertTSSatisfiesExpression(node, opts) {
|
||||
assert("TSSatisfiesExpression", node, opts);
|
||||
}
|
||||
|
||||
function assertTSTypeAssertion(node, opts) {
|
||||
assert("TSTypeAssertion", node, opts);
|
||||
}
|
||||
|
||||
Generated
Vendored
+9
@@ -216,6 +216,7 @@ exports.tSParenthesizedType = exports.tsParenthesizedType = tsParenthesizedType;
|
||||
exports.tSPropertySignature = exports.tsPropertySignature = tsPropertySignature;
|
||||
exports.tSQualifiedName = exports.tsQualifiedName = tsQualifiedName;
|
||||
exports.tSRestType = exports.tsRestType = tsRestType;
|
||||
exports.tSSatisfiesExpression = exports.tsSatisfiesExpression = tsSatisfiesExpression;
|
||||
exports.tSStringKeyword = exports.tsStringKeyword = tsStringKeyword;
|
||||
exports.tSSymbolKeyword = exports.tsSymbolKeyword = tsSymbolKeyword;
|
||||
exports.tSThisType = exports.tsThisType = tsThisType;
|
||||
@@ -2091,6 +2092,14 @@ function tsAsExpression(expression, typeAnnotation) {
|
||||
});
|
||||
}
|
||||
|
||||
function tsSatisfiesExpression(expression, typeAnnotation) {
|
||||
return (0, _validateNode.default)({
|
||||
type: "TSSatisfiesExpression",
|
||||
expression,
|
||||
typeAnnotation
|
||||
});
|
||||
}
|
||||
|
||||
function tsTypeAssertion(typeAnnotation, expression) {
|
||||
return (0, _validateNode.default)({
|
||||
type: "TSTypeAssertion",
|
||||
|
||||
Generated
Vendored
+6
@@ -1233,6 +1233,12 @@ Object.defineProperty(exports, "TSRestType", {
|
||||
return _index.tsRestType;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "TSSatisfiesExpression", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index.tsSatisfiesExpression;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "TSStringKeyword", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
|
||||
+30
-34
@@ -45,7 +45,7 @@ defineType("AssignmentExpression", {
|
||||
}()
|
||||
},
|
||||
left: {
|
||||
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal") : (0, _utils.assertNodeType)("Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern", "TSAsExpression", "TSTypeAssertion", "TSNonNullExpression")
|
||||
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal") : (0, _utils.assertNodeType)("Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern", "TSAsExpression", "TSSatisfiesExpression", "TSTypeAssertion", "TSNonNullExpression")
|
||||
},
|
||||
right: {
|
||||
validate: (0, _utils.assertNodeType)("Expression")
|
||||
@@ -249,7 +249,7 @@ defineType("ForInStatement", {
|
||||
aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"],
|
||||
fields: {
|
||||
left: {
|
||||
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("VariableDeclaration", "LVal") : (0, _utils.assertNodeType)("VariableDeclaration", "Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern", "TSAsExpression", "TSTypeAssertion", "TSNonNullExpression")
|
||||
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("VariableDeclaration", "LVal") : (0, _utils.assertNodeType)("VariableDeclaration", "Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern", "TSAsExpression", "TSSatisfiesExpression", "TSTypeAssertion", "TSNonNullExpression")
|
||||
},
|
||||
right: {
|
||||
validate: (0, _utils.assertNodeType)("Expression")
|
||||
@@ -680,7 +680,7 @@ defineType("ObjectProperty", {
|
||||
visitor: ["key", "value", "decorators"],
|
||||
aliases: ["UserWhitespacable", "Property", "ObjectMember"],
|
||||
validate: function () {
|
||||
const pattern = (0, _utils.assertNodeType)("Identifier", "Pattern", "TSAsExpression", "TSNonNullExpression", "TSTypeAssertion");
|
||||
const pattern = (0, _utils.assertNodeType)("Identifier", "Pattern", "TSAsExpression", "TSSatisfiesExpression", "TSNonNullExpression", "TSTypeAssertion");
|
||||
const expression = (0, _utils.assertNodeType)("Expression");
|
||||
return function (parent, key, node) {
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) return;
|
||||
@@ -696,7 +696,7 @@ defineType("RestElement", {
|
||||
deprecatedAlias: "RestProperty",
|
||||
fields: Object.assign({}, patternLikeCommon(), {
|
||||
argument: {
|
||||
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal") : (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern", "MemberExpression", "TSAsExpression", "TSTypeAssertion", "TSNonNullExpression")
|
||||
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal") : (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern", "MemberExpression", "TSAsExpression", "TSSatisfiesExpression", "TSTypeAssertion", "TSNonNullExpression")
|
||||
},
|
||||
optional: {
|
||||
validate: (0, _utils.assertValueType)("boolean"),
|
||||
@@ -847,7 +847,7 @@ defineType("VariableDeclaration", {
|
||||
optional: true
|
||||
},
|
||||
kind: {
|
||||
validate: (0, _utils.assertOneOf)("var", "let", "const")
|
||||
validate: (0, _utils.assertOneOf)("var", "let", "const", "using")
|
||||
},
|
||||
declarations: {
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("VariableDeclarator")))
|
||||
@@ -923,7 +923,7 @@ defineType("AssignmentPattern", {
|
||||
aliases: ["Pattern", "PatternLike", "LVal"],
|
||||
fields: Object.assign({}, patternLikeCommon(), {
|
||||
left: {
|
||||
validate: (0, _utils.assertNodeType)("Identifier", "ObjectPattern", "ArrayPattern", "MemberExpression", "TSAsExpression", "TSTypeAssertion", "TSNonNullExpression")
|
||||
validate: (0, _utils.assertNodeType)("Identifier", "ObjectPattern", "ArrayPattern", "MemberExpression", "TSAsExpression", "TSSatisfiesExpression", "TSTypeAssertion", "TSNonNullExpression")
|
||||
},
|
||||
right: {
|
||||
validate: (0, _utils.assertNodeType)("Expression")
|
||||
@@ -1166,7 +1166,7 @@ defineType("ForOfStatement", {
|
||||
}
|
||||
|
||||
const declaration = (0, _utils.assertNodeType)("VariableDeclaration");
|
||||
const lval = (0, _utils.assertNodeType)("Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern", "TSAsExpression", "TSTypeAssertion", "TSNonNullExpression");
|
||||
const lval = (0, _utils.assertNodeType)("Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern", "TSAsExpression", "TSSatisfiesExpression", "TSTypeAssertion", "TSNonNullExpression");
|
||||
return function (node, key, val) {
|
||||
if ((0, _is.default)("VariableDeclaration", val)) {
|
||||
declaration(node, key, val);
|
||||
@@ -1195,6 +1195,10 @@ defineType("ImportDeclaration", {
|
||||
optional: true,
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute")))
|
||||
},
|
||||
module: {
|
||||
optional: true,
|
||||
validate: (0, _utils.assertValueType)("boolean")
|
||||
},
|
||||
specifiers: {
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportSpecifier", "ImportDefaultSpecifier", "ImportNamespaceSpecifier")))
|
||||
},
|
||||
@@ -1398,37 +1402,29 @@ defineType("TemplateElement", {
|
||||
}
|
||||
}), function templateElementCookedValidator(node) {
|
||||
const raw = node.value.raw;
|
||||
let str,
|
||||
containsInvalid,
|
||||
unterminatedCalled = false;
|
||||
let unterminatedCalled = false;
|
||||
|
||||
try {
|
||||
const error = () => {
|
||||
throw new Error();
|
||||
};
|
||||
const error = () => {
|
||||
throw new Error("Internal @babel/types error.");
|
||||
};
|
||||
|
||||
({
|
||||
str,
|
||||
containsInvalid
|
||||
} = (0, _helperStringParser.readStringContents)("template", raw, 0, 0, 0, {
|
||||
unterminated() {
|
||||
unterminatedCalled = true;
|
||||
},
|
||||
|
||||
strictNumericEscape: error,
|
||||
invalidEscapeSequence: error,
|
||||
numericSeparatorInEscapeSequence: error,
|
||||
unexpectedNumericSeparator: error,
|
||||
invalidDigit: error,
|
||||
invalidCodePoint: error
|
||||
}));
|
||||
} catch (_unused) {
|
||||
unterminatedCalled = true;
|
||||
containsInvalid = true;
|
||||
}
|
||||
const {
|
||||
str,
|
||||
firstInvalidLoc
|
||||
} = (0, _helperStringParser.readStringContents)("template", raw, 0, 0, 0, {
|
||||
unterminated() {
|
||||
unterminatedCalled = true;
|
||||
},
|
||||
|
||||
strictNumericEscape: error,
|
||||
invalidEscapeSequence: error,
|
||||
numericSeparatorInEscapeSequence: error,
|
||||
unexpectedNumericSeparator: error,
|
||||
invalidDigit: error,
|
||||
invalidCodePoint: error
|
||||
});
|
||||
if (!unterminatedCalled) throw new Error("Invalid raw");
|
||||
node.value.cooked = containsInvalid ? null : str;
|
||||
node.value.cooked = firstInvalidLoc ? null : str;
|
||||
})
|
||||
},
|
||||
tail: {
|
||||
|
||||
Generated
Vendored
+5
-3
@@ -344,14 +344,16 @@ defineType("TSInstantiationExpression", {
|
||||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation")
|
||||
}
|
||||
});
|
||||
defineType("TSAsExpression", {
|
||||
const TSTypeExpression = {
|
||||
aliases: ["Expression", "LVal", "PatternLike"],
|
||||
visitor: ["expression", "typeAnnotation"],
|
||||
fields: {
|
||||
expression: (0, _utils.validateType)("Expression"),
|
||||
typeAnnotation: (0, _utils.validateType)("TSType")
|
||||
}
|
||||
});
|
||||
};
|
||||
defineType("TSAsExpression", TSTypeExpression);
|
||||
defineType("TSSatisfiesExpression", TSTypeExpression);
|
||||
defineType("TSTypeAssertion", {
|
||||
aliases: ["Expression", "LVal", "PatternLike"],
|
||||
visitor: ["typeAnnotation", "expression"],
|
||||
@@ -389,7 +391,7 @@ defineType("TSModuleDeclaration", {
|
||||
}
|
||||
});
|
||||
defineType("TSModuleBlock", {
|
||||
aliases: ["Scopable", "Block", "BlockParent"],
|
||||
aliases: ["Scopable", "Block", "BlockParent", "FunctionParent"],
|
||||
visitor: ["body"],
|
||||
fields: {
|
||||
body: (0, _utils.validateArrayOfType)("Statement")
|
||||
|
||||
+19
-9
@@ -350,7 +350,7 @@ declare class BabelNodeUpdateExpression extends BabelNode {
|
||||
|
||||
declare class BabelNodeVariableDeclaration extends BabelNode {
|
||||
type: "VariableDeclaration";
|
||||
kind: "var" | "let" | "const";
|
||||
kind: "var" | "let" | "const" | "using";
|
||||
declarations: Array<BabelNodeVariableDeclarator>;
|
||||
declare?: boolean;
|
||||
}
|
||||
@@ -376,7 +376,7 @@ declare class BabelNodeWithStatement extends BabelNode {
|
||||
|
||||
declare class BabelNodeAssignmentPattern extends BabelNode {
|
||||
type: "AssignmentPattern";
|
||||
left: BabelNodeIdentifier | BabelNodeObjectPattern | BabelNodeArrayPattern | BabelNodeMemberExpression | BabelNodeTSAsExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression;
|
||||
left: BabelNodeIdentifier | BabelNodeObjectPattern | BabelNodeArrayPattern | BabelNodeMemberExpression | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression;
|
||||
right: BabelNodeExpression;
|
||||
decorators?: Array<BabelNodeDecorator>;
|
||||
typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop;
|
||||
@@ -473,6 +473,7 @@ declare class BabelNodeImportDeclaration extends BabelNode {
|
||||
source: BabelNodeStringLiteral;
|
||||
assertions?: Array<BabelNodeImportAttribute>;
|
||||
importKind?: "type" | "typeof" | "value";
|
||||
module?: boolean;
|
||||
}
|
||||
|
||||
declare class BabelNodeImportDefaultSpecifier extends BabelNode {
|
||||
@@ -1519,6 +1520,12 @@ declare class BabelNodeTSAsExpression extends BabelNode {
|
||||
typeAnnotation: BabelNodeTSType;
|
||||
}
|
||||
|
||||
declare class BabelNodeTSSatisfiesExpression extends BabelNode {
|
||||
type: "TSSatisfiesExpression";
|
||||
expression: BabelNodeExpression;
|
||||
typeAnnotation: BabelNodeTSType;
|
||||
}
|
||||
|
||||
declare class BabelNodeTSTypeAssertion extends BabelNode {
|
||||
type: "TSTypeAssertion";
|
||||
typeAnnotation: BabelNodeTSType;
|
||||
@@ -1610,7 +1617,7 @@ declare class BabelNodeTSTypeParameter extends BabelNode {
|
||||
}
|
||||
|
||||
type BabelNodeStandardized = BabelNodeArrayExpression | BabelNodeAssignmentExpression | BabelNodeBinaryExpression | BabelNodeInterpreterDirective | BabelNodeDirective | BabelNodeDirectiveLiteral | BabelNodeBlockStatement | BabelNodeBreakStatement | BabelNodeCallExpression | BabelNodeCatchClause | BabelNodeConditionalExpression | BabelNodeContinueStatement | BabelNodeDebuggerStatement | BabelNodeDoWhileStatement | BabelNodeEmptyStatement | BabelNodeExpressionStatement | BabelNodeFile | BabelNodeForInStatement | BabelNodeForStatement | BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeIdentifier | BabelNodeIfStatement | BabelNodeLabeledStatement | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeLogicalExpression | BabelNodeMemberExpression | BabelNodeNewExpression | BabelNodeProgram | BabelNodeObjectExpression | BabelNodeObjectMethod | BabelNodeObjectProperty | BabelNodeRestElement | BabelNodeReturnStatement | BabelNodeSequenceExpression | BabelNodeParenthesizedExpression | BabelNodeSwitchCase | BabelNodeSwitchStatement | BabelNodeThisExpression | BabelNodeThrowStatement | BabelNodeTryStatement | BabelNodeUnaryExpression | BabelNodeUpdateExpression | BabelNodeVariableDeclaration | BabelNodeVariableDeclarator | BabelNodeWhileStatement | BabelNodeWithStatement | BabelNodeAssignmentPattern | BabelNodeArrayPattern | BabelNodeArrowFunctionExpression | BabelNodeClassBody | BabelNodeClassExpression | BabelNodeClassDeclaration | BabelNodeExportAllDeclaration | BabelNodeExportDefaultDeclaration | BabelNodeExportNamedDeclaration | BabelNodeExportSpecifier | BabelNodeForOfStatement | BabelNodeImportDeclaration | BabelNodeImportDefaultSpecifier | BabelNodeImportNamespaceSpecifier | BabelNodeImportSpecifier | BabelNodeMetaProperty | BabelNodeClassMethod | BabelNodeObjectPattern | BabelNodeSpreadElement | BabelNodeSuper | BabelNodeTaggedTemplateExpression | BabelNodeTemplateElement | BabelNodeTemplateLiteral | BabelNodeYieldExpression | BabelNodeAwaitExpression | BabelNodeImport | BabelNodeBigIntLiteral | BabelNodeExportNamespaceSpecifier | BabelNodeOptionalMemberExpression | BabelNodeOptionalCallExpression | BabelNodeClassProperty | BabelNodeClassAccessorProperty | BabelNodeClassPrivateProperty | BabelNodeClassPrivateMethod | BabelNodePrivateName | BabelNodeStaticBlock;
|
||||
type BabelNodeExpression = BabelNodeArrayExpression | BabelNodeAssignmentExpression | BabelNodeBinaryExpression | BabelNodeCallExpression | BabelNodeConditionalExpression | BabelNodeFunctionExpression | BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeLogicalExpression | BabelNodeMemberExpression | BabelNodeNewExpression | BabelNodeObjectExpression | BabelNodeSequenceExpression | BabelNodeParenthesizedExpression | BabelNodeThisExpression | BabelNodeUnaryExpression | BabelNodeUpdateExpression | BabelNodeArrowFunctionExpression | BabelNodeClassExpression | BabelNodeMetaProperty | BabelNodeSuper | BabelNodeTaggedTemplateExpression | BabelNodeTemplateLiteral | BabelNodeYieldExpression | BabelNodeAwaitExpression | BabelNodeImport | BabelNodeBigIntLiteral | BabelNodeOptionalMemberExpression | BabelNodeOptionalCallExpression | BabelNodeTypeCastExpression | BabelNodeJSXElement | BabelNodeJSXFragment | BabelNodeBindExpression | BabelNodeDoExpression | BabelNodeRecordExpression | BabelNodeTupleExpression | BabelNodeDecimalLiteral | BabelNodeModuleExpression | BabelNodeTopicReference | BabelNodePipelineTopicExpression | BabelNodePipelineBareFunction | BabelNodePipelinePrimaryTopicReference | BabelNodeTSInstantiationExpression | BabelNodeTSAsExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression;
|
||||
type BabelNodeExpression = BabelNodeArrayExpression | BabelNodeAssignmentExpression | BabelNodeBinaryExpression | BabelNodeCallExpression | BabelNodeConditionalExpression | BabelNodeFunctionExpression | BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeLogicalExpression | BabelNodeMemberExpression | BabelNodeNewExpression | BabelNodeObjectExpression | BabelNodeSequenceExpression | BabelNodeParenthesizedExpression | BabelNodeThisExpression | BabelNodeUnaryExpression | BabelNodeUpdateExpression | BabelNodeArrowFunctionExpression | BabelNodeClassExpression | BabelNodeMetaProperty | BabelNodeSuper | BabelNodeTaggedTemplateExpression | BabelNodeTemplateLiteral | BabelNodeYieldExpression | BabelNodeAwaitExpression | BabelNodeImport | BabelNodeBigIntLiteral | BabelNodeOptionalMemberExpression | BabelNodeOptionalCallExpression | BabelNodeTypeCastExpression | BabelNodeJSXElement | BabelNodeJSXFragment | BabelNodeBindExpression | BabelNodeDoExpression | BabelNodeRecordExpression | BabelNodeTupleExpression | BabelNodeDecimalLiteral | BabelNodeModuleExpression | BabelNodeTopicReference | BabelNodePipelineTopicExpression | BabelNodePipelineBareFunction | BabelNodePipelinePrimaryTopicReference | BabelNodeTSInstantiationExpression | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression;
|
||||
type BabelNodeBinary = BabelNodeBinaryExpression | BabelNodeLogicalExpression;
|
||||
type BabelNodeScopable = BabelNodeBlockStatement | BabelNodeCatchClause | BabelNodeDoWhileStatement | BabelNodeForInStatement | BabelNodeForStatement | BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeProgram | BabelNodeObjectMethod | BabelNodeSwitchStatement | BabelNodeWhileStatement | BabelNodeArrowFunctionExpression | BabelNodeClassExpression | BabelNodeClassDeclaration | BabelNodeForOfStatement | BabelNodeClassMethod | BabelNodeClassPrivateMethod | BabelNodeStaticBlock | BabelNodeTSModuleBlock;
|
||||
type BabelNodeBlockParent = BabelNodeBlockStatement | BabelNodeCatchClause | BabelNodeDoWhileStatement | BabelNodeForInStatement | BabelNodeForStatement | BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeProgram | BabelNodeObjectMethod | BabelNodeSwitchStatement | BabelNodeWhileStatement | BabelNodeArrowFunctionExpression | BabelNodeForOfStatement | BabelNodeClassMethod | BabelNodeClassPrivateMethod | BabelNodeStaticBlock | BabelNodeTSModuleBlock;
|
||||
@@ -1625,11 +1632,11 @@ type BabelNodeExpressionWrapper = BabelNodeExpressionStatement | BabelNodeParent
|
||||
type BabelNodeFor = BabelNodeForInStatement | BabelNodeForStatement | BabelNodeForOfStatement;
|
||||
type BabelNodeForXStatement = BabelNodeForInStatement | BabelNodeForOfStatement;
|
||||
type BabelNodeFunction = BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeObjectMethod | BabelNodeArrowFunctionExpression | BabelNodeClassMethod | BabelNodeClassPrivateMethod;
|
||||
type BabelNodeFunctionParent = BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeObjectMethod | BabelNodeArrowFunctionExpression | BabelNodeClassMethod | BabelNodeClassPrivateMethod | BabelNodeStaticBlock;
|
||||
type BabelNodeFunctionParent = BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeObjectMethod | BabelNodeArrowFunctionExpression | BabelNodeClassMethod | BabelNodeClassPrivateMethod | BabelNodeStaticBlock | BabelNodeTSModuleBlock;
|
||||
type BabelNodePureish = BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeArrowFunctionExpression | BabelNodeBigIntLiteral | BabelNodeDecimalLiteral;
|
||||
type BabelNodeDeclaration = BabelNodeFunctionDeclaration | BabelNodeVariableDeclaration | BabelNodeClassDeclaration | BabelNodeExportAllDeclaration | BabelNodeExportDefaultDeclaration | BabelNodeExportNamedDeclaration | BabelNodeImportDeclaration | BabelNodeDeclareClass | BabelNodeDeclareFunction | BabelNodeDeclareInterface | BabelNodeDeclareModule | BabelNodeDeclareModuleExports | BabelNodeDeclareTypeAlias | BabelNodeDeclareOpaqueType | BabelNodeDeclareVariable | BabelNodeDeclareExportDeclaration | BabelNodeDeclareExportAllDeclaration | BabelNodeInterfaceDeclaration | BabelNodeOpaqueType | BabelNodeTypeAlias | BabelNodeEnumDeclaration | BabelNodeTSDeclareFunction | BabelNodeTSInterfaceDeclaration | BabelNodeTSTypeAliasDeclaration | BabelNodeTSEnumDeclaration | BabelNodeTSModuleDeclaration;
|
||||
type BabelNodePatternLike = BabelNodeIdentifier | BabelNodeRestElement | BabelNodeAssignmentPattern | BabelNodeArrayPattern | BabelNodeObjectPattern | BabelNodeTSAsExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression;
|
||||
type BabelNodeLVal = BabelNodeIdentifier | BabelNodeMemberExpression | BabelNodeRestElement | BabelNodeAssignmentPattern | BabelNodeArrayPattern | BabelNodeObjectPattern | BabelNodeTSParameterProperty | BabelNodeTSAsExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression;
|
||||
type BabelNodePatternLike = BabelNodeIdentifier | BabelNodeRestElement | BabelNodeAssignmentPattern | BabelNodeArrayPattern | BabelNodeObjectPattern | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression;
|
||||
type BabelNodeLVal = BabelNodeIdentifier | BabelNodeMemberExpression | BabelNodeRestElement | BabelNodeAssignmentPattern | BabelNodeArrayPattern | BabelNodeObjectPattern | BabelNodeTSParameterProperty | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression;
|
||||
type BabelNodeTSEntityName = BabelNodeIdentifier | BabelNodeTSQualifiedName;
|
||||
type BabelNodeLiteral = BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeTemplateLiteral | BabelNodeBigIntLiteral | BabelNodeDecimalLiteral;
|
||||
type BabelNodeImmutable = BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeBigIntLiteral | BabelNodeJSXAttribute | BabelNodeJSXClosingElement | BabelNodeJSXElement | BabelNodeJSXExpressionContainer | BabelNodeJSXSpreadChild | BabelNodeJSXOpeningElement | BabelNodeJSXText | BabelNodeJSXFragment | BabelNodeJSXOpeningFragment | BabelNodeJSXClosingFragment | BabelNodeDecimalLiteral;
|
||||
@@ -1654,7 +1661,7 @@ type BabelNodeEnumBody = BabelNodeEnumBooleanBody | BabelNodeEnumNumberBody | Ba
|
||||
type BabelNodeEnumMember = BabelNodeEnumBooleanMember | BabelNodeEnumNumberMember | BabelNodeEnumStringMember | BabelNodeEnumDefaultedMember;
|
||||
type BabelNodeJSX = BabelNodeJSXAttribute | BabelNodeJSXClosingElement | BabelNodeJSXElement | BabelNodeJSXEmptyExpression | BabelNodeJSXExpressionContainer | BabelNodeJSXSpreadChild | BabelNodeJSXIdentifier | BabelNodeJSXMemberExpression | BabelNodeJSXNamespacedName | BabelNodeJSXOpeningElement | BabelNodeJSXSpreadAttribute | BabelNodeJSXText | BabelNodeJSXFragment | BabelNodeJSXOpeningFragment | BabelNodeJSXClosingFragment;
|
||||
type BabelNodeMiscellaneous = BabelNodeNoop | BabelNodePlaceholder | BabelNodeV8IntrinsicIdentifier;
|
||||
type BabelNodeTypeScript = BabelNodeTSParameterProperty | BabelNodeTSDeclareFunction | BabelNodeTSDeclareMethod | BabelNodeTSQualifiedName | BabelNodeTSCallSignatureDeclaration | BabelNodeTSConstructSignatureDeclaration | BabelNodeTSPropertySignature | BabelNodeTSMethodSignature | BabelNodeTSIndexSignature | BabelNodeTSAnyKeyword | BabelNodeTSBooleanKeyword | BabelNodeTSBigIntKeyword | BabelNodeTSIntrinsicKeyword | BabelNodeTSNeverKeyword | BabelNodeTSNullKeyword | BabelNodeTSNumberKeyword | BabelNodeTSObjectKeyword | BabelNodeTSStringKeyword | BabelNodeTSSymbolKeyword | BabelNodeTSUndefinedKeyword | BabelNodeTSUnknownKeyword | BabelNodeTSVoidKeyword | BabelNodeTSThisType | BabelNodeTSFunctionType | BabelNodeTSConstructorType | BabelNodeTSTypeReference | BabelNodeTSTypePredicate | BabelNodeTSTypeQuery | BabelNodeTSTypeLiteral | BabelNodeTSArrayType | BabelNodeTSTupleType | BabelNodeTSOptionalType | BabelNodeTSRestType | BabelNodeTSNamedTupleMember | BabelNodeTSUnionType | BabelNodeTSIntersectionType | BabelNodeTSConditionalType | BabelNodeTSInferType | BabelNodeTSParenthesizedType | BabelNodeTSTypeOperator | BabelNodeTSIndexedAccessType | BabelNodeTSMappedType | BabelNodeTSLiteralType | BabelNodeTSExpressionWithTypeArguments | BabelNodeTSInterfaceDeclaration | BabelNodeTSInterfaceBody | BabelNodeTSTypeAliasDeclaration | BabelNodeTSInstantiationExpression | BabelNodeTSAsExpression | BabelNodeTSTypeAssertion | BabelNodeTSEnumDeclaration | BabelNodeTSEnumMember | BabelNodeTSModuleDeclaration | BabelNodeTSModuleBlock | BabelNodeTSImportType | BabelNodeTSImportEqualsDeclaration | BabelNodeTSExternalModuleReference | BabelNodeTSNonNullExpression | BabelNodeTSExportAssignment | BabelNodeTSNamespaceExportDeclaration | BabelNodeTSTypeAnnotation | BabelNodeTSTypeParameterInstantiation | BabelNodeTSTypeParameterDeclaration | BabelNodeTSTypeParameter;
|
||||
type BabelNodeTypeScript = BabelNodeTSParameterProperty | BabelNodeTSDeclareFunction | BabelNodeTSDeclareMethod | BabelNodeTSQualifiedName | BabelNodeTSCallSignatureDeclaration | BabelNodeTSConstructSignatureDeclaration | BabelNodeTSPropertySignature | BabelNodeTSMethodSignature | BabelNodeTSIndexSignature | BabelNodeTSAnyKeyword | BabelNodeTSBooleanKeyword | BabelNodeTSBigIntKeyword | BabelNodeTSIntrinsicKeyword | BabelNodeTSNeverKeyword | BabelNodeTSNullKeyword | BabelNodeTSNumberKeyword | BabelNodeTSObjectKeyword | BabelNodeTSStringKeyword | BabelNodeTSSymbolKeyword | BabelNodeTSUndefinedKeyword | BabelNodeTSUnknownKeyword | BabelNodeTSVoidKeyword | BabelNodeTSThisType | BabelNodeTSFunctionType | BabelNodeTSConstructorType | BabelNodeTSTypeReference | BabelNodeTSTypePredicate | BabelNodeTSTypeQuery | BabelNodeTSTypeLiteral | BabelNodeTSArrayType | BabelNodeTSTupleType | BabelNodeTSOptionalType | BabelNodeTSRestType | BabelNodeTSNamedTupleMember | BabelNodeTSUnionType | BabelNodeTSIntersectionType | BabelNodeTSConditionalType | BabelNodeTSInferType | BabelNodeTSParenthesizedType | BabelNodeTSTypeOperator | BabelNodeTSIndexedAccessType | BabelNodeTSMappedType | BabelNodeTSLiteralType | BabelNodeTSExpressionWithTypeArguments | BabelNodeTSInterfaceDeclaration | BabelNodeTSInterfaceBody | BabelNodeTSTypeAliasDeclaration | BabelNodeTSInstantiationExpression | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSEnumDeclaration | BabelNodeTSEnumMember | BabelNodeTSModuleDeclaration | BabelNodeTSModuleBlock | BabelNodeTSImportType | BabelNodeTSImportEqualsDeclaration | BabelNodeTSExternalModuleReference | BabelNodeTSNonNullExpression | BabelNodeTSExportAssignment | BabelNodeTSNamespaceExportDeclaration | BabelNodeTSTypeAnnotation | BabelNodeTSTypeParameterInstantiation | BabelNodeTSTypeParameterDeclaration | BabelNodeTSTypeParameter;
|
||||
type BabelNodeTSTypeElement = BabelNodeTSCallSignatureDeclaration | BabelNodeTSConstructSignatureDeclaration | BabelNodeTSPropertySignature | BabelNodeTSMethodSignature | BabelNodeTSIndexSignature;
|
||||
type BabelNodeTSType = BabelNodeTSAnyKeyword | BabelNodeTSBooleanKeyword | BabelNodeTSBigIntKeyword | BabelNodeTSIntrinsicKeyword | BabelNodeTSNeverKeyword | BabelNodeTSNullKeyword | BabelNodeTSNumberKeyword | BabelNodeTSObjectKeyword | BabelNodeTSStringKeyword | BabelNodeTSSymbolKeyword | BabelNodeTSUndefinedKeyword | BabelNodeTSUnknownKeyword | BabelNodeTSVoidKeyword | BabelNodeTSThisType | BabelNodeTSFunctionType | BabelNodeTSConstructorType | BabelNodeTSTypeReference | BabelNodeTSTypePredicate | BabelNodeTSTypeQuery | BabelNodeTSTypeLiteral | BabelNodeTSArrayType | BabelNodeTSTupleType | BabelNodeTSOptionalType | BabelNodeTSRestType | BabelNodeTSUnionType | BabelNodeTSIntersectionType | BabelNodeTSConditionalType | BabelNodeTSInferType | BabelNodeTSParenthesizedType | BabelNodeTSTypeOperator | BabelNodeTSIndexedAccessType | BabelNodeTSMappedType | BabelNodeTSLiteralType | BabelNodeTSExpressionWithTypeArguments | BabelNodeTSImportType;
|
||||
type BabelNodeTSBaseType = BabelNodeTSAnyKeyword | BabelNodeTSBooleanKeyword | BabelNodeTSBigIntKeyword | BabelNodeTSIntrinsicKeyword | BabelNodeTSNeverKeyword | BabelNodeTSNullKeyword | BabelNodeTSNumberKeyword | BabelNodeTSObjectKeyword | BabelNodeTSStringKeyword | BabelNodeTSSymbolKeyword | BabelNodeTSUndefinedKeyword | BabelNodeTSUnknownKeyword | BabelNodeTSVoidKeyword | BabelNodeTSThisType | BabelNodeTSLiteralType;
|
||||
@@ -1707,11 +1714,11 @@ declare module "@babel/types" {
|
||||
declare export function tryStatement(block: BabelNodeBlockStatement, handler?: BabelNodeCatchClause, finalizer?: BabelNodeBlockStatement): BabelNodeTryStatement;
|
||||
declare export function unaryExpression(operator: "void" | "throw" | "delete" | "!" | "+" | "-" | "~" | "typeof", argument: BabelNodeExpression, prefix?: boolean): BabelNodeUnaryExpression;
|
||||
declare export function updateExpression(operator: "++" | "--", argument: BabelNodeExpression, prefix?: boolean): BabelNodeUpdateExpression;
|
||||
declare export function variableDeclaration(kind: "var" | "let" | "const", declarations: Array<BabelNodeVariableDeclarator>): BabelNodeVariableDeclaration;
|
||||
declare export function variableDeclaration(kind: "var" | "let" | "const" | "using", declarations: Array<BabelNodeVariableDeclarator>): BabelNodeVariableDeclaration;
|
||||
declare export function variableDeclarator(id: BabelNodeLVal, init?: BabelNodeExpression): BabelNodeVariableDeclarator;
|
||||
declare export function whileStatement(test: BabelNodeExpression, body: BabelNodeStatement): BabelNodeWhileStatement;
|
||||
declare export function withStatement(object: BabelNodeExpression, body: BabelNodeStatement): BabelNodeWithStatement;
|
||||
declare export function assignmentPattern(left: BabelNodeIdentifier | BabelNodeObjectPattern | BabelNodeArrayPattern | BabelNodeMemberExpression | BabelNodeTSAsExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression, right: BabelNodeExpression): BabelNodeAssignmentPattern;
|
||||
declare export function assignmentPattern(left: BabelNodeIdentifier | BabelNodeObjectPattern | BabelNodeArrayPattern | BabelNodeMemberExpression | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression, right: BabelNodeExpression): BabelNodeAssignmentPattern;
|
||||
declare export function arrayPattern(elements: Array<null | BabelNodePatternLike | BabelNodeLVal>): BabelNodeArrayPattern;
|
||||
declare export function arrowFunctionExpression(params: Array<BabelNodeIdentifier | BabelNodePattern | BabelNodeRestElement>, body: BabelNodeBlockStatement | BabelNodeExpression, async?: boolean): BabelNodeArrowFunctionExpression;
|
||||
declare export function classBody(body: Array<BabelNodeClassMethod | BabelNodeClassPrivateMethod | BabelNodeClassProperty | BabelNodeClassPrivateProperty | BabelNodeClassAccessorProperty | BabelNodeTSDeclareMethod | BabelNodeTSIndexSignature | BabelNodeStaticBlock>): BabelNodeClassBody;
|
||||
@@ -1895,6 +1902,7 @@ declare module "@babel/types" {
|
||||
declare export function tsTypeAliasDeclaration(id: BabelNodeIdentifier, typeParameters?: BabelNodeTSTypeParameterDeclaration, typeAnnotation: BabelNodeTSType): BabelNodeTSTypeAliasDeclaration;
|
||||
declare export function tsInstantiationExpression(expression: BabelNodeExpression, typeParameters?: BabelNodeTSTypeParameterInstantiation): BabelNodeTSInstantiationExpression;
|
||||
declare export function tsAsExpression(expression: BabelNodeExpression, typeAnnotation: BabelNodeTSType): BabelNodeTSAsExpression;
|
||||
declare export function tsSatisfiesExpression(expression: BabelNodeExpression, typeAnnotation: BabelNodeTSType): BabelNodeTSSatisfiesExpression;
|
||||
declare export function tsTypeAssertion(typeAnnotation: BabelNodeTSType, expression: BabelNodeExpression): BabelNodeTSTypeAssertion;
|
||||
declare export function tsEnumDeclaration(id: BabelNodeIdentifier, members: Array<BabelNodeTSEnumMember>): BabelNodeTSEnumDeclaration;
|
||||
declare export function tsEnumMember(id: BabelNodeIdentifier | BabelNodeStringLiteral, initializer?: BabelNodeExpression): BabelNodeTSEnumMember;
|
||||
@@ -2376,6 +2384,8 @@ declare module "@babel/types" {
|
||||
declare export function assertTSInstantiationExpression(node: ?Object, opts?: ?Object): void
|
||||
declare export function isTSAsExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSAsExpression)
|
||||
declare export function assertTSAsExpression(node: ?Object, opts?: ?Object): void
|
||||
declare export function isTSSatisfiesExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSSatisfiesExpression)
|
||||
declare export function assertTSSatisfiesExpression(node: ?Object, opts?: ?Object): void
|
||||
declare export function isTSTypeAssertion(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSTypeAssertion)
|
||||
declare export function assertTSTypeAssertion(node: ?Object, opts?: ?Object): void
|
||||
declare export function isTSEnumDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSEnumDeclaration)
|
||||
|
||||
Generated
Vendored
+21
-5
@@ -250,6 +250,7 @@ exports.isTSParenthesizedType = isTSParenthesizedType;
|
||||
exports.isTSPropertySignature = isTSPropertySignature;
|
||||
exports.isTSQualifiedName = isTSQualifiedName;
|
||||
exports.isTSRestType = isTSRestType;
|
||||
exports.isTSSatisfiesExpression = isTSSatisfiesExpression;
|
||||
exports.isTSStringKeyword = isTSStringKeyword;
|
||||
exports.isTSSymbolKeyword = isTSSymbolKeyword;
|
||||
exports.isTSThisType = isTSThisType;
|
||||
@@ -3802,6 +3803,21 @@ function isTSAsExpression(node, opts) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function isTSSatisfiesExpression(node, opts) {
|
||||
if (!node) return false;
|
||||
const nodeType = node.type;
|
||||
|
||||
if (nodeType === "TSSatisfiesExpression") {
|
||||
if (typeof opts === "undefined") {
|
||||
return true;
|
||||
} else {
|
||||
return (0, _shallowEqual.default)(node, opts);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isTSTypeAssertion(node, opts) {
|
||||
if (!node) return false;
|
||||
const nodeType = node.type;
|
||||
@@ -4046,7 +4062,7 @@ function isExpression(node, opts) {
|
||||
if (!node) return false;
|
||||
const nodeType = node.type;
|
||||
|
||||
if ("ArrayExpression" === nodeType || "AssignmentExpression" === nodeType || "BinaryExpression" === nodeType || "CallExpression" === nodeType || "ConditionalExpression" === nodeType || "FunctionExpression" === nodeType || "Identifier" === nodeType || "StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "RegExpLiteral" === nodeType || "LogicalExpression" === nodeType || "MemberExpression" === nodeType || "NewExpression" === nodeType || "ObjectExpression" === nodeType || "SequenceExpression" === nodeType || "ParenthesizedExpression" === nodeType || "ThisExpression" === nodeType || "UnaryExpression" === nodeType || "UpdateExpression" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassExpression" === nodeType || "MetaProperty" === nodeType || "Super" === nodeType || "TaggedTemplateExpression" === nodeType || "TemplateLiteral" === nodeType || "YieldExpression" === nodeType || "AwaitExpression" === nodeType || "Import" === nodeType || "BigIntLiteral" === nodeType || "OptionalMemberExpression" === nodeType || "OptionalCallExpression" === nodeType || "TypeCastExpression" === nodeType || "JSXElement" === nodeType || "JSXFragment" === nodeType || "BindExpression" === nodeType || "DoExpression" === nodeType || "RecordExpression" === nodeType || "TupleExpression" === nodeType || "DecimalLiteral" === nodeType || "ModuleExpression" === nodeType || "TopicReference" === nodeType || "PipelineTopicExpression" === nodeType || "PipelineBareFunction" === nodeType || "PipelinePrimaryTopicReference" === nodeType || "TSInstantiationExpression" === nodeType || "TSAsExpression" === nodeType || "TSTypeAssertion" === nodeType || "TSNonNullExpression" === nodeType || nodeType === "Placeholder" && ("Expression" === node.expectedNode || "Identifier" === node.expectedNode || "StringLiteral" === node.expectedNode)) {
|
||||
if ("ArrayExpression" === nodeType || "AssignmentExpression" === nodeType || "BinaryExpression" === nodeType || "CallExpression" === nodeType || "ConditionalExpression" === nodeType || "FunctionExpression" === nodeType || "Identifier" === nodeType || "StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "RegExpLiteral" === nodeType || "LogicalExpression" === nodeType || "MemberExpression" === nodeType || "NewExpression" === nodeType || "ObjectExpression" === nodeType || "SequenceExpression" === nodeType || "ParenthesizedExpression" === nodeType || "ThisExpression" === nodeType || "UnaryExpression" === nodeType || "UpdateExpression" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassExpression" === nodeType || "MetaProperty" === nodeType || "Super" === nodeType || "TaggedTemplateExpression" === nodeType || "TemplateLiteral" === nodeType || "YieldExpression" === nodeType || "AwaitExpression" === nodeType || "Import" === nodeType || "BigIntLiteral" === nodeType || "OptionalMemberExpression" === nodeType || "OptionalCallExpression" === nodeType || "TypeCastExpression" === nodeType || "JSXElement" === nodeType || "JSXFragment" === nodeType || "BindExpression" === nodeType || "DoExpression" === nodeType || "RecordExpression" === nodeType || "TupleExpression" === nodeType || "DecimalLiteral" === nodeType || "ModuleExpression" === nodeType || "TopicReference" === nodeType || "PipelineTopicExpression" === nodeType || "PipelineBareFunction" === nodeType || "PipelinePrimaryTopicReference" === nodeType || "TSInstantiationExpression" === nodeType || "TSAsExpression" === nodeType || "TSSatisfiesExpression" === nodeType || "TSTypeAssertion" === nodeType || "TSNonNullExpression" === nodeType || nodeType === "Placeholder" && ("Expression" === node.expectedNode || "Identifier" === node.expectedNode || "StringLiteral" === node.expectedNode)) {
|
||||
if (typeof opts === "undefined") {
|
||||
return true;
|
||||
} else {
|
||||
@@ -4271,7 +4287,7 @@ function isFunctionParent(node, opts) {
|
||||
if (!node) return false;
|
||||
const nodeType = node.type;
|
||||
|
||||
if ("FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "ObjectMethod" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType || "StaticBlock" === nodeType) {
|
||||
if ("FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "ObjectMethod" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType || "StaticBlock" === nodeType || "TSModuleBlock" === nodeType) {
|
||||
if (typeof opts === "undefined") {
|
||||
return true;
|
||||
} else {
|
||||
@@ -4316,7 +4332,7 @@ function isPatternLike(node, opts) {
|
||||
if (!node) return false;
|
||||
const nodeType = node.type;
|
||||
|
||||
if ("Identifier" === nodeType || "RestElement" === nodeType || "AssignmentPattern" === nodeType || "ArrayPattern" === nodeType || "ObjectPattern" === nodeType || "TSAsExpression" === nodeType || "TSTypeAssertion" === nodeType || "TSNonNullExpression" === nodeType || nodeType === "Placeholder" && ("Pattern" === node.expectedNode || "Identifier" === node.expectedNode)) {
|
||||
if ("Identifier" === nodeType || "RestElement" === nodeType || "AssignmentPattern" === nodeType || "ArrayPattern" === nodeType || "ObjectPattern" === nodeType || "TSAsExpression" === nodeType || "TSSatisfiesExpression" === nodeType || "TSTypeAssertion" === nodeType || "TSNonNullExpression" === nodeType || nodeType === "Placeholder" && ("Pattern" === node.expectedNode || "Identifier" === node.expectedNode)) {
|
||||
if (typeof opts === "undefined") {
|
||||
return true;
|
||||
} else {
|
||||
@@ -4331,7 +4347,7 @@ function isLVal(node, opts) {
|
||||
if (!node) return false;
|
||||
const nodeType = node.type;
|
||||
|
||||
if ("Identifier" === nodeType || "MemberExpression" === nodeType || "RestElement" === nodeType || "AssignmentPattern" === nodeType || "ArrayPattern" === nodeType || "ObjectPattern" === nodeType || "TSParameterProperty" === nodeType || "TSAsExpression" === nodeType || "TSTypeAssertion" === nodeType || "TSNonNullExpression" === nodeType || nodeType === "Placeholder" && ("Pattern" === node.expectedNode || "Identifier" === node.expectedNode)) {
|
||||
if ("Identifier" === nodeType || "MemberExpression" === nodeType || "RestElement" === nodeType || "AssignmentPattern" === nodeType || "ArrayPattern" === nodeType || "ObjectPattern" === nodeType || "TSParameterProperty" === nodeType || "TSAsExpression" === nodeType || "TSSatisfiesExpression" === nodeType || "TSTypeAssertion" === nodeType || "TSNonNullExpression" === nodeType || nodeType === "Placeholder" && ("Pattern" === node.expectedNode || "Identifier" === node.expectedNode)) {
|
||||
if (typeof opts === "undefined") {
|
||||
return true;
|
||||
} else {
|
||||
@@ -4706,7 +4722,7 @@ function isTypeScript(node, opts) {
|
||||
if (!node) return false;
|
||||
const nodeType = node.type;
|
||||
|
||||
if ("TSParameterProperty" === nodeType || "TSDeclareFunction" === nodeType || "TSDeclareMethod" === nodeType || "TSQualifiedName" === nodeType || "TSCallSignatureDeclaration" === nodeType || "TSConstructSignatureDeclaration" === nodeType || "TSPropertySignature" === nodeType || "TSMethodSignature" === nodeType || "TSIndexSignature" === nodeType || "TSAnyKeyword" === nodeType || "TSBooleanKeyword" === nodeType || "TSBigIntKeyword" === nodeType || "TSIntrinsicKeyword" === nodeType || "TSNeverKeyword" === nodeType || "TSNullKeyword" === nodeType || "TSNumberKeyword" === nodeType || "TSObjectKeyword" === nodeType || "TSStringKeyword" === nodeType || "TSSymbolKeyword" === nodeType || "TSUndefinedKeyword" === nodeType || "TSUnknownKeyword" === nodeType || "TSVoidKeyword" === nodeType || "TSThisType" === nodeType || "TSFunctionType" === nodeType || "TSConstructorType" === nodeType || "TSTypeReference" === nodeType || "TSTypePredicate" === nodeType || "TSTypeQuery" === nodeType || "TSTypeLiteral" === nodeType || "TSArrayType" === nodeType || "TSTupleType" === nodeType || "TSOptionalType" === nodeType || "TSRestType" === nodeType || "TSNamedTupleMember" === nodeType || "TSUnionType" === nodeType || "TSIntersectionType" === nodeType || "TSConditionalType" === nodeType || "TSInferType" === nodeType || "TSParenthesizedType" === nodeType || "TSTypeOperator" === nodeType || "TSIndexedAccessType" === nodeType || "TSMappedType" === nodeType || "TSLiteralType" === nodeType || "TSExpressionWithTypeArguments" === nodeType || "TSInterfaceDeclaration" === nodeType || "TSInterfaceBody" === nodeType || "TSTypeAliasDeclaration" === nodeType || "TSInstantiationExpression" === nodeType || "TSAsExpression" === nodeType || "TSTypeAssertion" === nodeType || "TSEnumDeclaration" === nodeType || "TSEnumMember" === nodeType || "TSModuleDeclaration" === nodeType || "TSModuleBlock" === nodeType || "TSImportType" === nodeType || "TSImportEqualsDeclaration" === nodeType || "TSExternalModuleReference" === nodeType || "TSNonNullExpression" === nodeType || "TSExportAssignment" === nodeType || "TSNamespaceExportDeclaration" === nodeType || "TSTypeAnnotation" === nodeType || "TSTypeParameterInstantiation" === nodeType || "TSTypeParameterDeclaration" === nodeType || "TSTypeParameter" === nodeType) {
|
||||
if ("TSParameterProperty" === nodeType || "TSDeclareFunction" === nodeType || "TSDeclareMethod" === nodeType || "TSQualifiedName" === nodeType || "TSCallSignatureDeclaration" === nodeType || "TSConstructSignatureDeclaration" === nodeType || "TSPropertySignature" === nodeType || "TSMethodSignature" === nodeType || "TSIndexSignature" === nodeType || "TSAnyKeyword" === nodeType || "TSBooleanKeyword" === nodeType || "TSBigIntKeyword" === nodeType || "TSIntrinsicKeyword" === nodeType || "TSNeverKeyword" === nodeType || "TSNullKeyword" === nodeType || "TSNumberKeyword" === nodeType || "TSObjectKeyword" === nodeType || "TSStringKeyword" === nodeType || "TSSymbolKeyword" === nodeType || "TSUndefinedKeyword" === nodeType || "TSUnknownKeyword" === nodeType || "TSVoidKeyword" === nodeType || "TSThisType" === nodeType || "TSFunctionType" === nodeType || "TSConstructorType" === nodeType || "TSTypeReference" === nodeType || "TSTypePredicate" === nodeType || "TSTypeQuery" === nodeType || "TSTypeLiteral" === nodeType || "TSArrayType" === nodeType || "TSTupleType" === nodeType || "TSOptionalType" === nodeType || "TSRestType" === nodeType || "TSNamedTupleMember" === nodeType || "TSUnionType" === nodeType || "TSIntersectionType" === nodeType || "TSConditionalType" === nodeType || "TSInferType" === nodeType || "TSParenthesizedType" === nodeType || "TSTypeOperator" === nodeType || "TSIndexedAccessType" === nodeType || "TSMappedType" === nodeType || "TSLiteralType" === nodeType || "TSExpressionWithTypeArguments" === nodeType || "TSInterfaceDeclaration" === nodeType || "TSInterfaceBody" === nodeType || "TSTypeAliasDeclaration" === nodeType || "TSInstantiationExpression" === nodeType || "TSAsExpression" === nodeType || "TSSatisfiesExpression" === nodeType || "TSTypeAssertion" === nodeType || "TSEnumDeclaration" === nodeType || "TSEnumMember" === nodeType || "TSModuleDeclaration" === nodeType || "TSModuleBlock" === nodeType || "TSImportType" === nodeType || "TSImportEqualsDeclaration" === nodeType || "TSExternalModuleReference" === nodeType || "TSNonNullExpression" === nodeType || "TSExportAssignment" === nodeType || "TSNamespaceExportDeclaration" === nodeType || "TSTypeAnnotation" === nodeType || "TSTypeParameterInstantiation" === nodeType || "TSTypeParameterDeclaration" === nodeType || "TSTypeParameter" === nodeType) {
|
||||
if (typeof opts === "undefined") {
|
||||
return true;
|
||||
} else {
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/types",
|
||||
"version": "7.19.3",
|
||||
"version": "7.20.0",
|
||||
"description": "Babel Types is a Lodash-esque utility library for AST nodes",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-types",
|
||||
@@ -24,13 +24,13 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/helper-string-parser": "^7.18.10",
|
||||
"@babel/helper-string-parser": "^7.19.4",
|
||||
"@babel/helper-validator-identifier": "^7.19.1",
|
||||
"to-fast-properties": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/generator": "^7.19.3",
|
||||
"@babel/parser": "^7.19.3",
|
||||
"@babel/generator": "^7.20.0",
|
||||
"@babel/parser": "^7.20.0",
|
||||
"chalk": "^4.1.0",
|
||||
"glob": "^7.2.0"
|
||||
},
|
||||
|
||||
Generated
Vendored
-55
@@ -1,55 +0,0 @@
|
||||
import {
|
||||
DEPRECATED_KEYS,
|
||||
FLIPPED_ALIAS_KEYS,
|
||||
NODE_FIELDS,
|
||||
VISITOR_KEYS,
|
||||
} from "../../lib/index.js";
|
||||
|
||||
function addAssertHelper(type) {
|
||||
const result =
|
||||
NODE_FIELDS[type] || FLIPPED_ALIAS_KEYS[type]
|
||||
? `node is t.${type}`
|
||||
: "boolean";
|
||||
|
||||
return `export function assert${type}(node: object | null | undefined, opts?: object | null): asserts ${
|
||||
result === "boolean" ? "node" : result
|
||||
} {
|
||||
assert("${type}", node, opts) }
|
||||
`;
|
||||
}
|
||||
|
||||
export default function generateAsserts() {
|
||||
let output = `/*
|
||||
* This file is auto-generated! Do not modify it directly.
|
||||
* To re-generate run 'make build'
|
||||
*/
|
||||
import is from "../../validators/is";
|
||||
import type * as t from "../..";
|
||||
|
||||
function assert(type: string, node: any, opts?: any): void {
|
||||
if (!is(type, node, opts)) {
|
||||
throw new Error(
|
||||
\`Expected type "\${type}" with option \${JSON.stringify(opts)}, \` +
|
||||
\`but instead got "\${node.type}".\`,
|
||||
);
|
||||
}
|
||||
}\n\n`;
|
||||
|
||||
Object.keys(VISITOR_KEYS).forEach(type => {
|
||||
output += addAssertHelper(type);
|
||||
});
|
||||
|
||||
Object.keys(FLIPPED_ALIAS_KEYS).forEach(type => {
|
||||
output += addAssertHelper(type);
|
||||
});
|
||||
|
||||
Object.keys(DEPRECATED_KEYS).forEach(type => {
|
||||
const newType = DEPRECATED_KEYS[type];
|
||||
output += `export function assert${type}(node: any, opts: any): void {
|
||||
console.trace("The node type ${type} has been renamed to ${newType}");
|
||||
assert("${type}", node, opts);
|
||||
}\n`;
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
Generated
Vendored
-196
@@ -1,196 +0,0 @@
|
||||
import * as t from "../../lib/index.js";
|
||||
import stringifyValidator, {
|
||||
isValueType,
|
||||
} from "../utils/stringifyValidator.js";
|
||||
|
||||
const parentMaps = new Map([["File", new Set(["null"])]]);
|
||||
|
||||
function registerParentMaps(parent, nodes) {
|
||||
for (const node of nodes) {
|
||||
if (!parentMaps.has(node)) {
|
||||
parentMaps.set(node, new Set());
|
||||
}
|
||||
parentMaps.get(node).add(parent);
|
||||
}
|
||||
}
|
||||
|
||||
function getNodeTypesFromValidator(validator) {
|
||||
if (validator === undefined) return [];
|
||||
if (validator.each) {
|
||||
return getNodeTypesFromValidator(validator.each);
|
||||
}
|
||||
if (validator.chainOf) {
|
||||
return getNodeTypesFromValidator(validator.chainOf[1]);
|
||||
}
|
||||
let nodeTypes = [];
|
||||
if (validator.oneOfNodeTypes) {
|
||||
nodeTypes = validator.oneOfNodeTypes;
|
||||
}
|
||||
if (validator.oneOfNodeOrValueTypes) {
|
||||
nodeTypes = validator.oneOfNodeOrValueTypes.filter(
|
||||
type => !isValueType(type)
|
||||
);
|
||||
}
|
||||
return nodeTypes.flatMap(type => t.FLIPPED_ALIAS_KEYS[type] ?? type);
|
||||
}
|
||||
|
||||
export default function generateAstTypes() {
|
||||
let code = `// NOTE: This file is autogenerated. Do not modify.
|
||||
// See packages/babel-types/scripts/generators/ast-types.js for script used.
|
||||
|
||||
interface BaseComment {
|
||||
value: string;
|
||||
start?: number;
|
||||
end?: number;
|
||||
loc?: SourceLocation;
|
||||
// generator will skip the comment if ignore is true
|
||||
ignore?: boolean;
|
||||
type: "CommentBlock" | "CommentLine";
|
||||
}
|
||||
|
||||
export interface CommentBlock extends BaseComment {
|
||||
type: "CommentBlock";
|
||||
}
|
||||
|
||||
export interface CommentLine extends BaseComment {
|
||||
type: "CommentLine";
|
||||
}
|
||||
|
||||
export type Comment = CommentBlock | CommentLine;
|
||||
|
||||
export interface SourceLocation {
|
||||
start: {
|
||||
line: number;
|
||||
column: number;
|
||||
};
|
||||
|
||||
end: {
|
||||
line: number;
|
||||
column: number;
|
||||
};
|
||||
}
|
||||
|
||||
interface BaseNode {
|
||||
type: Node["type"];
|
||||
leadingComments?: Comment[] | null;
|
||||
innerComments?: Comment[] | null;
|
||||
trailingComments?: Comment[] | null;
|
||||
start?: number | null;
|
||||
end?: number | null;
|
||||
loc?: SourceLocation | null;
|
||||
range?: [number, number];
|
||||
extra?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export type CommentTypeShorthand = "leading" | "inner" | "trailing";
|
||||
|
||||
export type Node = ${t.TYPES.filter(k => !t.FLIPPED_ALIAS_KEYS[k])
|
||||
.sort()
|
||||
.join(" | ")};\n\n`;
|
||||
|
||||
const deprecatedAlias = {};
|
||||
for (const type in t.DEPRECATED_KEYS) {
|
||||
deprecatedAlias[t.DEPRECATED_KEYS[type]] = type;
|
||||
}
|
||||
for (const type in t.NODE_FIELDS) {
|
||||
const fields = t.NODE_FIELDS[type];
|
||||
const fieldNames = sortFieldNames(Object.keys(t.NODE_FIELDS[type]), type);
|
||||
const struct = [];
|
||||
|
||||
fieldNames.forEach(fieldName => {
|
||||
const field = fields[fieldName];
|
||||
// Future / annoying TODO:
|
||||
// MemberExpression.property, ObjectProperty.key and ObjectMethod.key need special cases; either:
|
||||
// - convert the declaration to chain() like ClassProperty.key and ClassMethod.key,
|
||||
// - declare an alias type for valid keys, detect the case and reuse it here,
|
||||
// - declare a disjoint union with, for example, ObjectPropertyBase,
|
||||
// ObjectPropertyLiteralKey and ObjectPropertyComputedKey, and declare ObjectProperty
|
||||
// as "ObjectPropertyBase & (ObjectPropertyLiteralKey | ObjectPropertyComputedKey)"
|
||||
let typeAnnotation = stringifyValidator(field.validate, "");
|
||||
|
||||
if (isNullable(field) && !hasDefault(field)) {
|
||||
typeAnnotation += " | null";
|
||||
}
|
||||
|
||||
const alphaNumeric = /^\w+$/;
|
||||
const optional = field.optional ? "?" : "";
|
||||
|
||||
if (t.isValidIdentifier(fieldName) || alphaNumeric.test(fieldName)) {
|
||||
struct.push(`${fieldName}${optional}: ${typeAnnotation};`);
|
||||
} else {
|
||||
struct.push(`"${fieldName}"${optional}: ${typeAnnotation};`);
|
||||
}
|
||||
|
||||
registerParentMaps(type, getNodeTypesFromValidator(field.validate));
|
||||
});
|
||||
|
||||
code += `export interface ${type} extends BaseNode {
|
||||
type: "${type}";
|
||||
${struct.join("\n ").trim()}
|
||||
}\n\n`;
|
||||
|
||||
if (deprecatedAlias[type]) {
|
||||
code += `/**
|
||||
* @deprecated Use \`${type}\`
|
||||
*/
|
||||
export interface ${deprecatedAlias[type]} extends BaseNode {
|
||||
type: "${deprecatedAlias[type]}";
|
||||
${struct.join("\n ").trim()}
|
||||
}\n\n
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
for (const type in t.FLIPPED_ALIAS_KEYS) {
|
||||
const types = t.FLIPPED_ALIAS_KEYS[type];
|
||||
code += `export type ${type} = ${types
|
||||
.map(type => `${type}`)
|
||||
.join(" | ")};\n`;
|
||||
}
|
||||
code += "\n";
|
||||
|
||||
code += "export interface Aliases {\n";
|
||||
for (const type in t.FLIPPED_ALIAS_KEYS) {
|
||||
code += ` ${type}: ${type};\n`;
|
||||
}
|
||||
code += "}\n\n";
|
||||
code += `export type DeprecatedAliases = ${Object.keys(
|
||||
t.DEPRECATED_KEYS
|
||||
).join(" | ")}\n\n`;
|
||||
|
||||
code += "export interface ParentMaps {\n";
|
||||
|
||||
registerParentMaps("null", [...Object.keys(t.DEPRECATED_KEYS)]);
|
||||
// todo: provide a better parent type for Placeholder, currently it acts
|
||||
// as a catch-all parent type for an abstract NodePath, s.t NodePath.parent must
|
||||
// be a Node if type has not been specified
|
||||
registerParentMaps("Node", ["Placeholder"]);
|
||||
|
||||
const parentMapsKeys = [...parentMaps.keys()].sort();
|
||||
for (const type of parentMapsKeys) {
|
||||
const deduplicated = [...parentMaps.get(type)].sort();
|
||||
code += ` ${type}: ${deduplicated.join(" | ")};\n`;
|
||||
}
|
||||
code += "}\n\n";
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
function hasDefault(field) {
|
||||
return field.default != null;
|
||||
}
|
||||
|
||||
function isNullable(field) {
|
||||
return field.optional || hasDefault(field);
|
||||
}
|
||||
|
||||
function sortFieldNames(fields, type) {
|
||||
return fields.sort((fieldA, fieldB) => {
|
||||
const indexA = t.BUILDER_KEYS[type].indexOf(fieldA);
|
||||
const indexB = t.BUILDER_KEYS[type].indexOf(fieldB);
|
||||
if (indexA === indexB) return fieldA < fieldB ? -1 : 1;
|
||||
if (indexA === -1) return 1;
|
||||
if (indexB === -1) return -1;
|
||||
return indexA - indexB;
|
||||
});
|
||||
}
|
||||
Generated
Vendored
-193
@@ -1,193 +0,0 @@
|
||||
import {
|
||||
BUILDER_KEYS,
|
||||
DEPRECATED_KEYS,
|
||||
NODE_FIELDS,
|
||||
toBindingIdentifierName,
|
||||
} from "../../lib/index.js";
|
||||
import formatBuilderName from "../utils/formatBuilderName.js";
|
||||
import lowerFirst from "../utils/lowerFirst.js";
|
||||
import stringifyValidator from "../utils/stringifyValidator.js";
|
||||
|
||||
function areAllRemainingFieldsNullable(fieldName, fieldNames, fields) {
|
||||
const index = fieldNames.indexOf(fieldName);
|
||||
return fieldNames.slice(index).every(_ => isNullable(fields[_]));
|
||||
}
|
||||
|
||||
function hasDefault(field) {
|
||||
return field.default != null;
|
||||
}
|
||||
|
||||
function isNullable(field) {
|
||||
return field.optional || hasDefault(field);
|
||||
}
|
||||
|
||||
function sortFieldNames(fields, type) {
|
||||
return fields.sort((fieldA, fieldB) => {
|
||||
const indexA = BUILDER_KEYS[type].indexOf(fieldA);
|
||||
const indexB = BUILDER_KEYS[type].indexOf(fieldB);
|
||||
if (indexA === indexB) return fieldA < fieldB ? -1 : 1;
|
||||
if (indexA === -1) return 1;
|
||||
if (indexB === -1) return -1;
|
||||
return indexA - indexB;
|
||||
});
|
||||
}
|
||||
|
||||
function generateBuilderArgs(type) {
|
||||
const fields = NODE_FIELDS[type];
|
||||
const fieldNames = sortFieldNames(Object.keys(NODE_FIELDS[type]), type);
|
||||
const builderNames = BUILDER_KEYS[type];
|
||||
|
||||
const args = [];
|
||||
|
||||
fieldNames.forEach(fieldName => {
|
||||
const field = fields[fieldName];
|
||||
// Future / annoying TODO:
|
||||
// MemberExpression.property, ObjectProperty.key and ObjectMethod.key need special cases; either:
|
||||
// - convert the declaration to chain() like ClassProperty.key and ClassMethod.key,
|
||||
// - declare an alias type for valid keys, detect the case and reuse it here,
|
||||
// - declare a disjoint union with, for example, ObjectPropertyBase,
|
||||
// ObjectPropertyLiteralKey and ObjectPropertyComputedKey, and declare ObjectProperty
|
||||
// as "ObjectPropertyBase & (ObjectPropertyLiteralKey | ObjectPropertyComputedKey)"
|
||||
let typeAnnotation = stringifyValidator(field.validate, "t.");
|
||||
|
||||
if (isNullable(field) && !hasDefault(field)) {
|
||||
typeAnnotation += " | null";
|
||||
}
|
||||
|
||||
if (builderNames.includes(fieldName)) {
|
||||
const field = NODE_FIELDS[type][fieldName];
|
||||
const def = JSON.stringify(field.default);
|
||||
const bindingIdentifierName = toBindingIdentifierName(fieldName);
|
||||
let arg;
|
||||
if (areAllRemainingFieldsNullable(fieldName, builderNames, fields)) {
|
||||
arg = `${bindingIdentifierName}${
|
||||
isNullable(field) && !def ? "?:" : ":"
|
||||
} ${typeAnnotation}`;
|
||||
} else {
|
||||
arg = `${bindingIdentifierName}: ${typeAnnotation}${
|
||||
isNullable(field) ? " | undefined" : ""
|
||||
}`;
|
||||
}
|
||||
if (def !== "null" || isNullable(field)) {
|
||||
arg += `= ${def}`;
|
||||
}
|
||||
args.push(arg);
|
||||
}
|
||||
});
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
export default function generateBuilders(kind) {
|
||||
return kind === "uppercase.js"
|
||||
? generateUppercaseBuilders()
|
||||
: generateLowercaseBuilders();
|
||||
}
|
||||
|
||||
function generateLowercaseBuilders() {
|
||||
let output = `/*
|
||||
* This file is auto-generated! Do not modify it directly.
|
||||
* To re-generate run 'make build'
|
||||
*/
|
||||
import validateNode from "../validateNode";
|
||||
import type * as t from "../..";
|
||||
`;
|
||||
|
||||
const reservedNames = new Set(["super", "import"]);
|
||||
Object.keys(BUILDER_KEYS).forEach(type => {
|
||||
const defArgs = generateBuilderArgs(type);
|
||||
const formatedBuilderName = formatBuilderName(type);
|
||||
const formatedBuilderNameLocal = reservedNames.has(formatedBuilderName)
|
||||
? `_${formatedBuilderName}`
|
||||
: formatedBuilderName;
|
||||
|
||||
const fieldNames = sortFieldNames(Object.keys(NODE_FIELDS[type]), type);
|
||||
const builderNames = BUILDER_KEYS[type];
|
||||
const objectFields = [["type", JSON.stringify(type)]];
|
||||
fieldNames.forEach(fieldName => {
|
||||
const field = NODE_FIELDS[type][fieldName];
|
||||
if (builderNames.includes(fieldName)) {
|
||||
const bindingIdentifierName = toBindingIdentifierName(fieldName);
|
||||
objectFields.push([fieldName, bindingIdentifierName]);
|
||||
} else if (!field.optional) {
|
||||
const def = JSON.stringify(field.default);
|
||||
objectFields.push([fieldName, def]);
|
||||
}
|
||||
});
|
||||
|
||||
output += `${
|
||||
formatedBuilderNameLocal === formatedBuilderName ? "export " : ""
|
||||
}function ${formatedBuilderNameLocal}(${defArgs.join(", ")}): t.${type} {`;
|
||||
|
||||
const nodeObjectExpression = `{\n${objectFields
|
||||
.map(([k, v]) => (k === v ? ` ${k},` : ` ${k}: ${v},`))
|
||||
.join("\n")}\n }`;
|
||||
|
||||
if (builderNames.length > 0) {
|
||||
output += `\n return validateNode<t.${type}>(${nodeObjectExpression});`;
|
||||
} else {
|
||||
output += `\n return ${nodeObjectExpression};`;
|
||||
}
|
||||
output += `\n}\n`;
|
||||
|
||||
if (formatedBuilderNameLocal !== formatedBuilderName) {
|
||||
output += `export { ${formatedBuilderNameLocal} as ${formatedBuilderName} };\n`;
|
||||
}
|
||||
|
||||
// This is needed for backwards compatibility.
|
||||
// It should be removed in the next major version.
|
||||
// JSXIdentifier -> jSXIdentifier
|
||||
if (/^[A-Z]{2}/.test(type)) {
|
||||
output += `export { ${formatedBuilderNameLocal} as ${lowerFirst(
|
||||
type
|
||||
)} }\n`;
|
||||
}
|
||||
});
|
||||
|
||||
Object.keys(DEPRECATED_KEYS).forEach(type => {
|
||||
const newType = DEPRECATED_KEYS[type];
|
||||
const formatedBuilderName = formatBuilderName(type);
|
||||
const formatedNewBuilderName = formatBuilderName(newType);
|
||||
output += `/** @deprecated */
|
||||
function ${type}(${generateBuilderArgs(newType).join(", ")}) {
|
||||
console.trace("The node type ${type} has been renamed to ${newType}");
|
||||
return ${formatedNewBuilderName}(${BUILDER_KEYS[newType].join(", ")});
|
||||
}
|
||||
export { ${type} as ${formatedBuilderName} };\n`;
|
||||
// This is needed for backwards compatibility.
|
||||
// It should be removed in the next major version.
|
||||
// JSXIdentifier -> jSXIdentifier
|
||||
if (/^[A-Z]{2}/.test(type)) {
|
||||
output += `export { ${type} as ${lowerFirst(type)} }\n`;
|
||||
}
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
function generateUppercaseBuilders() {
|
||||
let output = `/*
|
||||
* This file is auto-generated! Do not modify it directly.
|
||||
* To re-generate run 'make build'
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file is written in JavaScript and not TypeScript because uppercase builders
|
||||
* conflict with AST types. TypeScript reads the uppercase.d.ts file instead.
|
||||
*/
|
||||
|
||||
export {\n`;
|
||||
|
||||
Object.keys(BUILDER_KEYS).forEach(type => {
|
||||
const formatedBuilderName = formatBuilderName(type);
|
||||
output += ` ${formatedBuilderName} as ${type},\n`;
|
||||
});
|
||||
|
||||
Object.keys(DEPRECATED_KEYS).forEach(type => {
|
||||
const formatedBuilderName = formatBuilderName(type);
|
||||
output += ` ${formatedBuilderName} as ${type},\n`;
|
||||
});
|
||||
|
||||
output += ` } from './index';\n`;
|
||||
return output;
|
||||
}
|
||||
Generated
Vendored
-15
@@ -1,15 +0,0 @@
|
||||
import { FLIPPED_ALIAS_KEYS } from "../../lib/index.js";
|
||||
|
||||
export default function generateConstants() {
|
||||
let output = `/*
|
||||
* This file is auto-generated! Do not modify it directly.
|
||||
* To re-generate run 'make build'
|
||||
*/
|
||||
import { FLIPPED_ALIAS_KEYS } from "../../definitions";\n\n`;
|
||||
|
||||
Object.keys(FLIPPED_ALIAS_KEYS).forEach(type => {
|
||||
output += `export const ${type.toUpperCase()}_TYPES = FLIPPED_ALIAS_KEYS["${type}"];\n`;
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
-283
@@ -1,283 +0,0 @@
|
||||
import util from "util";
|
||||
import stringifyValidator from "../utils/stringifyValidator.js";
|
||||
import toFunctionName from "../utils/toFunctionName.js";
|
||||
|
||||
import * as t from "../../lib/index.js";
|
||||
|
||||
const readme = [
|
||||
`---
|
||||
id: babel-types
|
||||
title: @babel/types
|
||||
---
|
||||
<!-- Do not modify! This file is automatically generated by
|
||||
github.com/babel/babel/babel-types/scripts/generators/docs.js !-->
|
||||
|
||||
> This module contains methods for building ASTs manually and for checking the types of AST nodes.
|
||||
|
||||
## Install
|
||||
|
||||
\`\`\`sh
|
||||
npm install --save-dev @babel/types
|
||||
\`\`\`
|
||||
|
||||
## API`,
|
||||
];
|
||||
|
||||
const customTypes = {
|
||||
ClassMethod: {
|
||||
key: "if computed then `Expression` else `Identifier | Literal`",
|
||||
},
|
||||
Identifier: {
|
||||
name: "`string`",
|
||||
},
|
||||
MemberExpression: {
|
||||
property: "if computed then `Expression` else `Identifier`",
|
||||
},
|
||||
ObjectMethod: {
|
||||
key: "if computed then `Expression` else `Identifier | Literal`",
|
||||
},
|
||||
ObjectProperty: {
|
||||
key: "if computed then `Expression` else `Identifier | Literal`",
|
||||
},
|
||||
ClassPrivateMethod: {
|
||||
computed: "'false'",
|
||||
},
|
||||
ClassPrivateProperty: {
|
||||
computed: "'false'",
|
||||
},
|
||||
};
|
||||
const APIHistory = {
|
||||
ClassProperty: [["v7.6.0", "Supports `static`"]],
|
||||
};
|
||||
function formatHistory(historyItems) {
|
||||
const lines = historyItems.map(
|
||||
item => "| `" + item[0] + "` | " + item[1] + " |"
|
||||
);
|
||||
return [
|
||||
"<details>",
|
||||
" <summary>History</summary>",
|
||||
"| Version | Changes |",
|
||||
"| --- | --- |",
|
||||
...lines,
|
||||
"</details>",
|
||||
];
|
||||
}
|
||||
function printAPIHistory(key, readme) {
|
||||
if (APIHistory[key]) {
|
||||
readme.push("");
|
||||
readme.push(...formatHistory(APIHistory[key]));
|
||||
}
|
||||
}
|
||||
function printNodeFields(key, readme) {
|
||||
if (Object.keys(t.NODE_FIELDS[key]).length > 0) {
|
||||
readme.push("");
|
||||
readme.push("AST Node `" + key + "` shape:");
|
||||
Object.keys(t.NODE_FIELDS[key])
|
||||
.sort(function (fieldA, fieldB) {
|
||||
const indexA = t.BUILDER_KEYS[key].indexOf(fieldA);
|
||||
const indexB = t.BUILDER_KEYS[key].indexOf(fieldB);
|
||||
if (indexA === indexB) return fieldA < fieldB ? -1 : 1;
|
||||
if (indexA === -1) return 1;
|
||||
if (indexB === -1) return -1;
|
||||
return indexA - indexB;
|
||||
})
|
||||
.forEach(function (field) {
|
||||
const defaultValue = t.NODE_FIELDS[key][field].default;
|
||||
const fieldDescription = ["`" + field + "`"];
|
||||
const validator = t.NODE_FIELDS[key][field].validate;
|
||||
if (customTypes[key] && customTypes[key][field]) {
|
||||
fieldDescription.push(`: ${customTypes[key][field]}`);
|
||||
} else if (validator) {
|
||||
try {
|
||||
fieldDescription.push(
|
||||
": `" + stringifyValidator(validator, "") + "`"
|
||||
);
|
||||
} catch (ex) {
|
||||
if (ex.code === "UNEXPECTED_VALIDATOR_TYPE") {
|
||||
console.log(
|
||||
"Unrecognised validator type for " + key + "." + field
|
||||
);
|
||||
console.dir(ex.validator, { depth: 10, colors: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
if (defaultValue !== null || t.NODE_FIELDS[key][field].optional) {
|
||||
fieldDescription.push(
|
||||
" (default: `" + util.inspect(defaultValue) + "`"
|
||||
);
|
||||
if (t.BUILDER_KEYS[key].indexOf(field) < 0) {
|
||||
fieldDescription.push(", excluded from builder function");
|
||||
}
|
||||
fieldDescription.push(")");
|
||||
} else {
|
||||
fieldDescription.push(" (required)");
|
||||
}
|
||||
readme.push("- " + fieldDescription.join(""));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function printAliasKeys(key, readme) {
|
||||
if (t.ALIAS_KEYS[key] && t.ALIAS_KEYS[key].length) {
|
||||
readme.push("");
|
||||
readme.push(
|
||||
"Aliases: " +
|
||||
t.ALIAS_KEYS[key]
|
||||
.map(function (key) {
|
||||
return "[`" + key + "`](#" + key.toLowerCase() + ")";
|
||||
})
|
||||
.join(", ")
|
||||
);
|
||||
}
|
||||
}
|
||||
readme.push("### Node Builders");
|
||||
readme.push("");
|
||||
Object.keys(t.BUILDER_KEYS)
|
||||
.sort()
|
||||
.forEach(function (key) {
|
||||
readme.push("#### " + toFunctionName(key));
|
||||
readme.push("");
|
||||
readme.push("```javascript");
|
||||
readme.push(
|
||||
"t." + toFunctionName(key) + "(" + t.BUILDER_KEYS[key].join(", ") + ");"
|
||||
);
|
||||
readme.push("```");
|
||||
printAPIHistory(key, readme);
|
||||
readme.push("");
|
||||
readme.push(
|
||||
"See also `t.is" +
|
||||
key +
|
||||
"(node, opts)` and `t.assert" +
|
||||
key +
|
||||
"(node, opts)`."
|
||||
);
|
||||
|
||||
printNodeFields(key, readme);
|
||||
printAliasKeys(key, readme);
|
||||
|
||||
readme.push("");
|
||||
readme.push("---");
|
||||
readme.push("");
|
||||
});
|
||||
|
||||
function generateMapAliasToNodeTypes() {
|
||||
const result = new Map();
|
||||
for (const nodeType of Object.keys(t.ALIAS_KEYS)) {
|
||||
const aliases = t.ALIAS_KEYS[nodeType];
|
||||
if (!aliases) continue;
|
||||
for (const alias of aliases) {
|
||||
if (!result.has(alias)) {
|
||||
result.set(alias, []);
|
||||
}
|
||||
const nodeTypes = result.get(alias);
|
||||
nodeTypes.push(nodeType);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
const aliasDescriptions = {
|
||||
Accessor: "Deprecated. Will be removed in Babel 8.",
|
||||
Binary:
|
||||
"A cover of BinaryExpression and LogicalExpression, which share the same AST shape.",
|
||||
Block: "Deprecated. Will be removed in Babel 8.",
|
||||
BlockParent:
|
||||
"A cover of AST nodes that start an execution context with new [LexicalEnvironment](https://tc39.es/ecma262/#table-additional-state-components-for-ecmascript-code-execution-contexts). In other words, they define the scope of `let` and `const` declarations.",
|
||||
Class:
|
||||
"A cover of ClassExpression and ClassDeclaration, which share the same AST shape.",
|
||||
CompletionStatement:
|
||||
"A statement that indicates the [completion records](https://tc39.es/ecma262/#sec-completion-record-specification-type). In other words, they define the control flow of the program, such as when should a loop break or an action throws critical errors.",
|
||||
Conditional:
|
||||
"A cover of ConditionalExpression and IfStatement, which share the same AST shape.",
|
||||
Declaration:
|
||||
"A cover of any [Declaration](https://tc39.es/ecma262/#prod-Declaration)s.",
|
||||
EnumBody: "A cover of Flow enum bodies.",
|
||||
EnumMember: "A cover of Flow enum membors.",
|
||||
ExportDeclaration:
|
||||
"A cover of any [ExportDeclaration](https://tc39.es/ecma262/#prod-ExportDeclaration)s.",
|
||||
Expression:
|
||||
"A cover of any [Expression](https://tc39.es/ecma262/#sec-ecmascript-language-expressions)s.",
|
||||
ExpressionWrapper:
|
||||
"A wrapper of expression that does not have runtime semantics.",
|
||||
Flow: "A cover of AST nodes defined for Flow.",
|
||||
FlowBaseAnnotation: "A cover of primary Flow type annotations.",
|
||||
FlowDeclaration: "A cover of Flow declarations.",
|
||||
FlowPredicate: "A cover of Flow predicates.",
|
||||
FlowType: "A cover of Flow type annotations.",
|
||||
For: "A cover of [ForStatement](https://tc39.es/ecma262/#sec-for-statement)s and [ForXStatement](#forxstatement)s.",
|
||||
ForXStatement:
|
||||
"A cover of [ForInStatements and ForOfStatements](https://tc39.es/ecma262/#sec-for-in-and-for-of-statements).",
|
||||
Function:
|
||||
"A cover of functions and [method](#method)s, the must have `body` and `params`. Note: `Function` is different to `FunctionParent`. For example, a `StaticBlock` is a `FunctionParent` but not `Function`.",
|
||||
FunctionParent:
|
||||
"A cover of AST nodes that start an execution context with new [VariableEnvironment](https://tc39.es/ecma262/#table-additional-state-components-for-ecmascript-code-execution-contexts). In other words, they define the scope of `var` declarations. FunctionParent did not include `Program` since Babel 7.",
|
||||
Immutable:
|
||||
"A cover of immutable objects and JSX elements. An object is [immutable](https://tc39.es/ecma262/#immutable-prototype-exotic-object) if no other properties can be defined once created.",
|
||||
JSX: "A cover of AST nodes defined for [JSX](https://facebook.github.io/jsx/).",
|
||||
LVal: "A cover of left hand side expressions used in the `left` of assignment expressions and [ForXStatement](#forxstatement)s. ",
|
||||
Literal:
|
||||
"A cover of [Literal](https://tc39.es/ecma262/#sec-primary-expression-literals)s, [Regular Expression Literal](https://tc39.es/ecma262/#sec-primary-expression-regular-expression-literals)s and [Template Literal](https://tc39.es/ecma262/#sec-template-literals)s.",
|
||||
Loop: "A cover of loop statements.",
|
||||
Method: "A cover of object methods and class methods.",
|
||||
Miscellaneous:
|
||||
"A cover of non-standard AST types that are sometimes useful for development.",
|
||||
ModuleDeclaration:
|
||||
"A cover of ImportDeclaration and [ExportDeclaration](#exportdeclaration)",
|
||||
ModuleSpecifier:
|
||||
"A cover of import and export specifiers. Note: It is _not_ the [ModuleSpecifier](https://tc39.es/ecma262/#prod-ModuleSpecifier) defined in the spec.",
|
||||
ObjectMember:
|
||||
"A cover of [members](https://tc39.es/ecma262/#prod-PropertyDefinitionList) in an object literal.",
|
||||
Pattern:
|
||||
"A cover of [BindingPattern](https://tc39.es/ecma262/#prod-BindingPattern) except Identifiers.",
|
||||
PatternLike:
|
||||
"A cover of [BindingPattern](https://tc39.es/ecma262/#prod-BindingPattern)s. ",
|
||||
Private: "A cover of private class elements and private identifiers.",
|
||||
Property: "A cover of object properties and class properties.",
|
||||
Pureish:
|
||||
"A cover of AST nodes which do not have side-effects. In other words, there is no observable behaviour changes if they are evaluated more than once.",
|
||||
Scopable:
|
||||
"A cover of [FunctionParent](#functionparent) and [BlockParent](#blockparent).",
|
||||
Standardized:
|
||||
"A cover of AST nodes which are part of an official ECMAScript specification.",
|
||||
Statement:
|
||||
"A cover of any [Statement](https://tc39.es/ecma262/#prod-Statement)s.",
|
||||
TSBaseType: "A cover of primary TypeScript type annotations.",
|
||||
TSEntityName: "A cover of ts entities.",
|
||||
TSType: "A cover of TypeScript type annotations.",
|
||||
TSTypeElement: "A cover of TypeScript type declarations.",
|
||||
TypeScript: "A cover of AST nodes defined for TypeScript.",
|
||||
Terminatorless:
|
||||
"A cover of AST nodes whose semantic will change when a line terminator is inserted between the operator and the operand.",
|
||||
UnaryLike: "A cover of UnaryExpression and SpreadElement.",
|
||||
UserWhitespacable: "Deprecated. Will be removed in Babel 8.",
|
||||
While:
|
||||
"A cover of DoWhileStatement and WhileStatement, which share the same AST shape.",
|
||||
};
|
||||
const mapAliasToNodeTypes = generateMapAliasToNodeTypes();
|
||||
readme.push("### Aliases");
|
||||
readme.push("");
|
||||
for (const alias of [...mapAliasToNodeTypes.keys()].sort()) {
|
||||
const nodeTypes = mapAliasToNodeTypes.get(alias);
|
||||
nodeTypes.sort();
|
||||
if (!(alias in aliasDescriptions)) {
|
||||
throw new Error(
|
||||
'Missing alias descriptions of "' +
|
||||
alias +
|
||||
", which covers " +
|
||||
nodeTypes.join(",")
|
||||
);
|
||||
}
|
||||
readme.push("#### " + alias);
|
||||
readme.push("");
|
||||
readme.push(aliasDescriptions[alias]);
|
||||
readme.push("```javascript");
|
||||
readme.push("t.is" + alias + "(node);");
|
||||
readme.push("```");
|
||||
readme.push("");
|
||||
readme.push("Covered nodes: ");
|
||||
for (const nodeType of nodeTypes) {
|
||||
readme.push("- [`" + nodeType + "`](#" + nodeType.toLowerCase() + ")");
|
||||
}
|
||||
readme.push("");
|
||||
}
|
||||
|
||||
process.stdout.write(readme.join("\n"));
|
||||
-260
@@ -1,260 +0,0 @@
|
||||
import * as t from "../../lib/index.js";
|
||||
import stringifyValidator from "../utils/stringifyValidator.js";
|
||||
import toFunctionName from "../utils/toFunctionName.js";
|
||||
|
||||
const NODE_PREFIX = "BabelNode";
|
||||
|
||||
let code = `// NOTE: This file is autogenerated. Do not modify.
|
||||
// See packages/babel-types/scripts/generators/flow.js for script used.
|
||||
|
||||
declare class ${NODE_PREFIX}Comment {
|
||||
value: string;
|
||||
start: number;
|
||||
end: number;
|
||||
loc: ${NODE_PREFIX}SourceLocation;
|
||||
}
|
||||
|
||||
declare class ${NODE_PREFIX}CommentBlock extends ${NODE_PREFIX}Comment {
|
||||
type: "CommentBlock";
|
||||
}
|
||||
|
||||
declare class ${NODE_PREFIX}CommentLine extends ${NODE_PREFIX}Comment {
|
||||
type: "CommentLine";
|
||||
}
|
||||
|
||||
declare class ${NODE_PREFIX}SourceLocation {
|
||||
start: {
|
||||
line: number;
|
||||
column: number;
|
||||
};
|
||||
|
||||
end: {
|
||||
line: number;
|
||||
column: number;
|
||||
};
|
||||
}
|
||||
|
||||
declare class ${NODE_PREFIX} {
|
||||
leadingComments?: Array<${NODE_PREFIX}Comment>;
|
||||
innerComments?: Array<${NODE_PREFIX}Comment>;
|
||||
trailingComments?: Array<${NODE_PREFIX}Comment>;
|
||||
start: ?number;
|
||||
end: ?number;
|
||||
loc: ?${NODE_PREFIX}SourceLocation;
|
||||
extra?: { [string]: mixed };
|
||||
}\n\n`;
|
||||
|
||||
//
|
||||
|
||||
const lines = [];
|
||||
|
||||
for (const type in t.NODE_FIELDS) {
|
||||
const fields = t.NODE_FIELDS[type];
|
||||
|
||||
const struct = ['type: "' + type + '";'];
|
||||
const args = [];
|
||||
const builderNames = t.BUILDER_KEYS[type];
|
||||
|
||||
Object.keys(t.NODE_FIELDS[type])
|
||||
.sort((fieldA, fieldB) => {
|
||||
const indexA = t.BUILDER_KEYS[type].indexOf(fieldA);
|
||||
const indexB = t.BUILDER_KEYS[type].indexOf(fieldB);
|
||||
if (indexA === indexB) return fieldA < fieldB ? -1 : 1;
|
||||
if (indexA === -1) return 1;
|
||||
if (indexB === -1) return -1;
|
||||
return indexA - indexB;
|
||||
})
|
||||
.forEach(fieldName => {
|
||||
const field = fields[fieldName];
|
||||
|
||||
let suffix = "";
|
||||
if (field.optional || field.default != null) suffix += "?";
|
||||
|
||||
let typeAnnotation = "any";
|
||||
|
||||
const validate = field.validate;
|
||||
if (validate) {
|
||||
typeAnnotation = stringifyValidator(validate, NODE_PREFIX);
|
||||
}
|
||||
|
||||
if (typeAnnotation) {
|
||||
suffix += ": " + typeAnnotation;
|
||||
}
|
||||
if (builderNames.includes(fieldName)) {
|
||||
args.push(t.toBindingIdentifierName(fieldName) + suffix);
|
||||
}
|
||||
|
||||
if (t.isValidIdentifier(fieldName)) {
|
||||
struct.push(fieldName + suffix + ";");
|
||||
}
|
||||
});
|
||||
|
||||
code += `declare class ${NODE_PREFIX}${type} extends ${NODE_PREFIX} {
|
||||
${struct.join("\n ").trim()}
|
||||
}\n\n`;
|
||||
|
||||
// Flow chokes on super() and import() :/
|
||||
if (type !== "Super" && type !== "Import") {
|
||||
lines.push(
|
||||
`declare export function ${toFunctionName(type)}(${args.join(
|
||||
", "
|
||||
)}): ${NODE_PREFIX}${type};`
|
||||
);
|
||||
} else {
|
||||
const functionName = toFunctionName(type);
|
||||
lines.push(
|
||||
`declare function _${functionName}(${args.join(
|
||||
", "
|
||||
)}): ${NODE_PREFIX}${type};`,
|
||||
`declare export { _${functionName} as ${functionName} }`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (const typeName of t.TYPES) {
|
||||
const isDeprecated = !!t.DEPRECATED_KEYS[typeName];
|
||||
const realName = isDeprecated ? t.DEPRECATED_KEYS[typeName] : typeName;
|
||||
|
||||
let decl = `declare export function is${typeName}(node: ?Object, opts?: ?Object): boolean`;
|
||||
if (t.NODE_FIELDS[realName]) {
|
||||
decl += ` %checks (node instanceof ${NODE_PREFIX}${realName})`;
|
||||
}
|
||||
lines.push(decl);
|
||||
|
||||
lines.push(
|
||||
`declare export function assert${typeName}(node: ?Object, opts?: ?Object): void`
|
||||
);
|
||||
}
|
||||
|
||||
lines.push(
|
||||
`declare export var VISITOR_KEYS: { [type: string]: string[] }`,
|
||||
|
||||
// assert/
|
||||
`declare export function assertNode(obj: any): void`,
|
||||
|
||||
// builders/
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function createTypeAnnotationBasedOnTypeof(type: 'string' | 'number' | 'undefined' | 'boolean' | 'function' | 'object' | 'symbol'): ${NODE_PREFIX}TypeAnnotation`,
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function createUnionTypeAnnotation(types: Array<${NODE_PREFIX}FlowType>): ${NODE_PREFIX}UnionTypeAnnotation`,
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function createFlowUnionType(types: Array<${NODE_PREFIX}FlowType>): ${NODE_PREFIX}UnionTypeAnnotation`,
|
||||
// this smells like "internal API"
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function buildChildren(node: { children: Array<${NODE_PREFIX}JSXText | ${NODE_PREFIX}JSXExpressionContainer | ${NODE_PREFIX}JSXSpreadChild | ${NODE_PREFIX}JSXElement | ${NODE_PREFIX}JSXFragment | ${NODE_PREFIX}JSXEmptyExpression> }): Array<${NODE_PREFIX}JSXText | ${NODE_PREFIX}JSXExpressionContainer | ${NODE_PREFIX}JSXSpreadChild | ${NODE_PREFIX}JSXElement | ${NODE_PREFIX}JSXFragment>`,
|
||||
|
||||
// clone/
|
||||
`declare export function clone<T>(n: T): T;`,
|
||||
`declare export function cloneDeep<T>(n: T): T;`,
|
||||
`declare export function cloneDeepWithoutLoc<T>(n: T): T;`,
|
||||
`declare export function cloneNode<T>(n: T, deep?: boolean, withoutLoc?: boolean): T;`,
|
||||
`declare export function cloneWithoutLoc<T>(n: T): T;`,
|
||||
|
||||
// comments/
|
||||
`declare type CommentTypeShorthand = 'leading' | 'inner' | 'trailing'`,
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function addComment<T: BabelNode>(node: T, type: CommentTypeShorthand, content: string, line?: boolean): T`,
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function addComments<T: BabelNode>(node: T, type: CommentTypeShorthand, comments: Array<Comment>): T`,
|
||||
`declare export function inheritInnerComments(node: BabelNode, parent: BabelNode): void`,
|
||||
`declare export function inheritLeadingComments(node: BabelNode, parent: BabelNode): void`,
|
||||
`declare export function inheritsComments<T: BabelNode>(node: T, parent: BabelNode): void`,
|
||||
`declare export function inheritTrailingComments(node: BabelNode, parent: BabelNode): void`,
|
||||
`declare export function removeComments<T: BabelNode>(node: T): T`,
|
||||
|
||||
// converters/
|
||||
`declare export function ensureBlock(node: ${NODE_PREFIX}, key: string): ${NODE_PREFIX}BlockStatement`,
|
||||
`declare export function toBindingIdentifierName(name?: ?string): string`,
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function toBlock(node: ${NODE_PREFIX}Statement | ${NODE_PREFIX}Expression, parent?: ${NODE_PREFIX}Function | null): ${NODE_PREFIX}BlockStatement`,
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function toComputedKey(node: ${NODE_PREFIX}Method | ${NODE_PREFIX}Property, key?: ${NODE_PREFIX}Expression | ${NODE_PREFIX}Identifier): ${NODE_PREFIX}Expression`,
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function toExpression(node: ${NODE_PREFIX}ExpressionStatement | ${NODE_PREFIX}Expression | ${NODE_PREFIX}Class | ${NODE_PREFIX}Function): ${NODE_PREFIX}Expression`,
|
||||
`declare export function toIdentifier(name?: ?string): string`,
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function toKeyAlias(node: ${NODE_PREFIX}Method | ${NODE_PREFIX}Property, key?: ${NODE_PREFIX}): string`,
|
||||
// toSequenceExpression relies on types that aren't declared in flow
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function toStatement(node: ${NODE_PREFIX}Statement | ${NODE_PREFIX}Class | ${NODE_PREFIX}Function | ${NODE_PREFIX}AssignmentExpression, ignore?: boolean): ${NODE_PREFIX}Statement | void`,
|
||||
`declare export function valueToNode(value: any): ${NODE_PREFIX}Expression`,
|
||||
|
||||
// modifications/
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function removeTypeDuplicates(types: Array<${NODE_PREFIX}FlowType>): Array<${NODE_PREFIX}FlowType>`,
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function appendToMemberExpression(member: ${NODE_PREFIX}MemberExpression, append: ${NODE_PREFIX}, computed?: boolean): ${NODE_PREFIX}MemberExpression`,
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function inherits<T: BabelNode>(child: T, parent: ${NODE_PREFIX} | null | void): T`,
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function prependToMemberExpression(member: ${NODE_PREFIX}MemberExpression, prepend: ${NODE_PREFIX}Expression): ${NODE_PREFIX}MemberExpression`,
|
||||
`declare export function removeProperties<T>(n: T, opts: ?{}): void;`,
|
||||
`declare export function removePropertiesDeep<T>(n: T, opts: ?{}): T;`,
|
||||
|
||||
// retrievers/
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export var getBindingIdentifiers: {
|
||||
(node: ${NODE_PREFIX}, duplicates?: boolean, outerOnly?: boolean): { [key: string]: ${NODE_PREFIX}Identifier | Array<${NODE_PREFIX}Identifier> },
|
||||
keys: { [type: string]: string[] }
|
||||
}`,
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function getOuterBindingIdentifiers(node: BabelNode, duplicates?: boolean): { [key: string]: ${NODE_PREFIX}Identifier | Array<${NODE_PREFIX}Identifier> }`,
|
||||
|
||||
// traverse/
|
||||
`declare type TraversalAncestors = Array<{
|
||||
node: BabelNode,
|
||||
key: string,
|
||||
index?: number,
|
||||
}>;
|
||||
declare type TraversalHandler<T> = (BabelNode, TraversalAncestors, T) => void;
|
||||
declare type TraversalHandlers<T> = {
|
||||
enter?: TraversalHandler<T>,
|
||||
exit?: TraversalHandler<T>,
|
||||
};`.replace(/(^|\n) {2}/g, "$1"),
|
||||
// eslint-disable-next-line
|
||||
`declare export function traverse<T>(n: BabelNode, TraversalHandler<T> | TraversalHandlers<T>, state?: T): void;`,
|
||||
`declare export function traverseFast<T>(n: BabelNode, h: TraversalHandler<T>, state?: T): void;`,
|
||||
|
||||
// utils/
|
||||
// cleanJSXElementLiteralChild is not exported
|
||||
// inherit is not exported
|
||||
`declare export function shallowEqual(actual: Object, expected: Object): boolean`,
|
||||
|
||||
// validators/
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function buildMatchMemberExpression(match: string, allowPartial?: boolean): (?BabelNode) => boolean`,
|
||||
`declare export function is(type: string, n: BabelNode, opts: Object): boolean;`,
|
||||
`declare export function isBinding(node: BabelNode, parent: BabelNode, grandparent?: BabelNode): boolean`,
|
||||
`declare export function isBlockScoped(node: BabelNode): boolean`,
|
||||
`declare export function isImmutable(node: BabelNode): boolean`,
|
||||
`declare export function isLet(node: BabelNode): boolean`,
|
||||
`declare export function isNode(node: ?Object): boolean`,
|
||||
`declare export function isNodesEquivalent(a: any, b: any): boolean`,
|
||||
`declare export function isPlaceholderType(placeholderType: string, targetType: string): boolean`,
|
||||
`declare export function isReferenced(node: BabelNode, parent: BabelNode, grandparent?: BabelNode): boolean`,
|
||||
`declare export function isScope(node: BabelNode, parent: BabelNode): boolean`,
|
||||
`declare export function isSpecifierDefault(specifier: BabelNodeModuleSpecifier): boolean`,
|
||||
`declare export function isType(nodetype: ?string, targetType: string): boolean`,
|
||||
`declare export function isValidES3Identifier(name: string): boolean`,
|
||||
`declare export function isValidES3Identifier(name: string): boolean`,
|
||||
`declare export function isValidIdentifier(name: string): boolean`,
|
||||
`declare export function isVar(node: BabelNode): boolean`,
|
||||
// eslint-disable-next-line max-len
|
||||
`declare export function matchesPattern(node: ?BabelNode, match: string | Array<string>, allowPartial?: boolean): boolean`,
|
||||
`declare export function validate(n: BabelNode, key: string, value: mixed): void;`
|
||||
);
|
||||
|
||||
for (const type in t.FLIPPED_ALIAS_KEYS) {
|
||||
const types = t.FLIPPED_ALIAS_KEYS[type];
|
||||
code += `type ${NODE_PREFIX}${type} = ${types
|
||||
.map(type => `${NODE_PREFIX}${type}`)
|
||||
.join(" | ")};\n`;
|
||||
}
|
||||
|
||||
code += `\ndeclare module "@babel/types" {
|
||||
${lines.join("\n").replace(/\n/g, "\n ").trim()}
|
||||
}\n`;
|
||||
|
||||
//
|
||||
|
||||
process.stdout.write(code);
|
||||
Generated
Vendored
-369
@@ -1,369 +0,0 @@
|
||||
import * as t from "../../lib/index.js";
|
||||
import stringifyValidator from "../utils/stringifyValidator.js";
|
||||
import toFunctionName from "../utils/toFunctionName.js";
|
||||
|
||||
let code = `// NOTE: This file is autogenerated. Do not modify.
|
||||
// See packages/babel-types/scripts/generators/typescript-legacy.js for script used.
|
||||
|
||||
interface BaseComment {
|
||||
value: string;
|
||||
start: number;
|
||||
end: number;
|
||||
loc: SourceLocation;
|
||||
type: "CommentBlock" | "CommentLine";
|
||||
}
|
||||
|
||||
export interface CommentBlock extends BaseComment {
|
||||
type: "CommentBlock";
|
||||
}
|
||||
|
||||
export interface CommentLine extends BaseComment {
|
||||
type: "CommentLine";
|
||||
}
|
||||
|
||||
export type Comment = CommentBlock | CommentLine;
|
||||
|
||||
export interface SourceLocation {
|
||||
start: {
|
||||
line: number;
|
||||
column: number;
|
||||
};
|
||||
|
||||
end: {
|
||||
line: number;
|
||||
column: number;
|
||||
};
|
||||
}
|
||||
|
||||
interface BaseNode {
|
||||
leadingComments: ReadonlyArray<Comment> | null;
|
||||
innerComments: ReadonlyArray<Comment> | null;
|
||||
trailingComments: ReadonlyArray<Comment> | null;
|
||||
start: number | null;
|
||||
end: number | null;
|
||||
loc: SourceLocation | null;
|
||||
type: Node["type"];
|
||||
extra?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export type Node = ${t.TYPES.sort().join(" | ")};\n\n`;
|
||||
|
||||
//
|
||||
|
||||
const lines = [];
|
||||
|
||||
for (const type in t.NODE_FIELDS) {
|
||||
const fields = t.NODE_FIELDS[type];
|
||||
const fieldNames = sortFieldNames(Object.keys(t.NODE_FIELDS[type]), type);
|
||||
const builderNames = t.BUILDER_KEYS[type];
|
||||
|
||||
const struct = ['type: "' + type + '";'];
|
||||
const args = [];
|
||||
|
||||
fieldNames.forEach(fieldName => {
|
||||
const field = fields[fieldName];
|
||||
// Future / annoying TODO:
|
||||
// MemberExpression.property, ObjectProperty.key and ObjectMethod.key need special cases; either:
|
||||
// - convert the declaration to chain() like ClassProperty.key and ClassMethod.key,
|
||||
// - declare an alias type for valid keys, detect the case and reuse it here,
|
||||
// - declare a disjoint union with, for example, ObjectPropertyBase,
|
||||
// ObjectPropertyLiteralKey and ObjectPropertyComputedKey, and declare ObjectProperty
|
||||
// as "ObjectPropertyBase & (ObjectPropertyLiteralKey | ObjectPropertyComputedKey)"
|
||||
let typeAnnotation = stringifyValidator(field.validate, "");
|
||||
|
||||
if (isNullable(field) && !hasDefault(field)) {
|
||||
typeAnnotation += " | null";
|
||||
}
|
||||
|
||||
if (builderNames.includes(fieldName)) {
|
||||
if (areAllRemainingFieldsNullable(fieldName, builderNames, fields)) {
|
||||
args.push(
|
||||
`${t.toBindingIdentifierName(fieldName)}${
|
||||
isNullable(field) ? "?:" : ":"
|
||||
} ${typeAnnotation}`
|
||||
);
|
||||
} else {
|
||||
args.push(
|
||||
`${t.toBindingIdentifierName(fieldName)}: ${typeAnnotation}${
|
||||
isNullable(field) ? " | undefined" : ""
|
||||
}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const alphaNumeric = /^\w+$/;
|
||||
|
||||
if (t.isValidIdentifier(fieldName) || alphaNumeric.test(fieldName)) {
|
||||
struct.push(`${fieldName}: ${typeAnnotation};`);
|
||||
} else {
|
||||
struct.push(`"${fieldName}": ${typeAnnotation};`);
|
||||
}
|
||||
});
|
||||
|
||||
code += `export interface ${type} extends BaseNode {
|
||||
${struct.join("\n ").trim()}
|
||||
}\n\n`;
|
||||
|
||||
// super and import are reserved words in JavaScript
|
||||
if (type !== "Super" && type !== "Import") {
|
||||
lines.push(
|
||||
`export function ${toFunctionName(type)}(${args.join(", ")}): ${type};`
|
||||
);
|
||||
} else {
|
||||
const functionName = toFunctionName(type);
|
||||
lines.push(
|
||||
`declare function _${functionName}(${args.join(", ")}): ${type};`,
|
||||
`export { _${functionName} as ${functionName}}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (const typeName of t.TYPES) {
|
||||
const isDeprecated = !!t.DEPRECATED_KEYS[typeName];
|
||||
const realName = isDeprecated ? t.DEPRECATED_KEYS[typeName] : typeName;
|
||||
|
||||
const result =
|
||||
t.NODE_FIELDS[realName] || t.FLIPPED_ALIAS_KEYS[realName]
|
||||
? `node is ${realName}`
|
||||
: "boolean";
|
||||
|
||||
if (isDeprecated) {
|
||||
lines.push(`/** @deprecated Use \`is${realName}\` */`);
|
||||
}
|
||||
lines.push(
|
||||
`export function is${typeName}(node: object | null | undefined, opts?: object | null): ${result};`
|
||||
);
|
||||
|
||||
if (isDeprecated) {
|
||||
lines.push(`/** @deprecated Use \`assert${realName}\` */`);
|
||||
}
|
||||
lines.push(
|
||||
`export function assert${typeName}(node: object | null | undefined, opts?: object | null): void;`
|
||||
);
|
||||
}
|
||||
|
||||
lines.push(
|
||||
// assert/
|
||||
`export function assertNode(obj: any): void`,
|
||||
|
||||
// builders/
|
||||
// eslint-disable-next-line max-len
|
||||
`export function createTypeAnnotationBasedOnTypeof(type: 'string' | 'number' | 'undefined' | 'boolean' | 'function' | 'object' | 'symbol'): StringTypeAnnotation | VoidTypeAnnotation | NumberTypeAnnotation | BooleanTypeAnnotation | GenericTypeAnnotation`,
|
||||
`export function createUnionTypeAnnotation<T extends FlowType>(types: [T]): T`,
|
||||
`export function createFlowUnionType<T extends FlowType>(types: [T]): T`,
|
||||
// this probably misbehaves if there are 0 elements, and it's not a UnionTypeAnnotation if there's only 1
|
||||
// it is possible to require "2 or more" for this overload ([T, T, ...T[]]) but it requires typescript 3.0
|
||||
`export function createUnionTypeAnnotation(types: ReadonlyArray<FlowType>): UnionTypeAnnotation`,
|
||||
`export function createFlowUnionType(types: ReadonlyArray<FlowType>): UnionTypeAnnotation`,
|
||||
// this smells like "internal API"
|
||||
// eslint-disable-next-line max-len
|
||||
`export function buildChildren(node: { children: ReadonlyArray<JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment | JSXEmptyExpression> }): JSXElement['children']`,
|
||||
|
||||
// clone/
|
||||
`export function clone<T extends Node>(n: T): T;`,
|
||||
`export function cloneDeep<T extends Node>(n: T): T;`,
|
||||
`export function cloneDeepWithoutLoc<T extends Node>(n: T): T;`,
|
||||
`export function cloneNode<T extends Node>(n: T, deep?: boolean, withoutLoc?: boolean): T;`,
|
||||
`export function cloneWithoutLoc<T extends Node>(n: T): T;`,
|
||||
|
||||
// comments/
|
||||
`export type CommentTypeShorthand = 'leading' | 'inner' | 'trailing'`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function addComment<T extends Node>(node: T, type: CommentTypeShorthand, content: string, line?: boolean): T`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function addComments<T extends Node>(node: T, type: CommentTypeShorthand, comments: ReadonlyArray<Comment>): T`,
|
||||
`export function inheritInnerComments(node: Node, parent: Node): void`,
|
||||
`export function inheritLeadingComments(node: Node, parent: Node): void`,
|
||||
`export function inheritsComments<T extends Node>(node: T, parent: Node): void`,
|
||||
`export function inheritTrailingComments(node: Node, parent: Node): void`,
|
||||
`export function removeComments<T extends Node>(node: T): T`,
|
||||
|
||||
// converters/
|
||||
// eslint-disable-next-line max-len
|
||||
`export function ensureBlock(node: Extract<Node, { body: BlockStatement | Statement | Expression }>): BlockStatement`,
|
||||
// too complex?
|
||||
// eslint-disable-next-line max-len
|
||||
`export function ensureBlock<K extends keyof Extract<Node, { body: BlockStatement | Statement | Expression }> = 'body'>(node: Extract<Node, Record<K, BlockStatement | Statement | Expression>>, key: K): BlockStatement`,
|
||||
// gatherSequenceExpressions is not exported
|
||||
`export function toBindingIdentifierName(name: { toString(): string } | null | undefined): string`,
|
||||
`export function toBlock(node: Statement | Expression, parent?: Function | null): BlockStatement`,
|
||||
// it is possible for `node` to be an arbitrary object if `key` is always provided,
|
||||
// but that doesn't look like intended API
|
||||
// eslint-disable-next-line max-len
|
||||
`export function toComputedKey<T extends Extract<Node, { computed: boolean | null }>>(node: T, key?: Expression | Identifier): Expression`,
|
||||
`export function toExpression(node: Function): FunctionExpression`,
|
||||
`export function toExpression(node: Class): ClassExpression`,
|
||||
`export function toExpression(node: ExpressionStatement | Expression | Class | Function): Expression`,
|
||||
`export function toIdentifier(name: { toString(): string } | null | undefined): string`,
|
||||
`export function toKeyAlias(node: Method | Property, key?: Node): string`,
|
||||
// NOTE: this actually uses Scope from @babel/traverse, but we can't add a dependency on its types,
|
||||
// as they live in @types. Declare the structural subset that is required.
|
||||
// eslint-disable-next-line max-len
|
||||
`export function toSequenceExpression(nodes: ReadonlyArray<Node>, scope: { push(value: { id: LVal; kind: 'var'; init?: Expression}): void; buildUndefinedNode(): Node }): SequenceExpression | undefined`,
|
||||
`export function toStatement(node: AssignmentExpression, ignore?: boolean): ExpressionStatement`,
|
||||
`export function toStatement(node: Statement | AssignmentExpression, ignore?: boolean): Statement`,
|
||||
`export function toStatement(node: Class, ignore: true): ClassDeclaration | undefined`,
|
||||
`export function toStatement(node: Class, ignore?: boolean): ClassDeclaration`,
|
||||
`export function toStatement(node: Function, ignore: true): FunctionDeclaration | undefined`,
|
||||
`export function toStatement(node: Function, ignore?: boolean): FunctionDeclaration`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function toStatement(node: Statement | Class | Function | AssignmentExpression, ignore: true): Statement | undefined`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function toStatement(node: Statement | Class | Function | AssignmentExpression, ignore?: boolean): Statement`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function valueToNode(value: undefined): Identifier`, // (should this not be a UnaryExpression to avoid shadowing?)
|
||||
`export function valueToNode(value: boolean): BooleanLiteral`,
|
||||
`export function valueToNode(value: null): NullLiteral`,
|
||||
`export function valueToNode(value: string): StringLiteral`,
|
||||
// Infinities and NaN need to use a BinaryExpression; negative values must be wrapped in UnaryExpression
|
||||
`export function valueToNode(value: number): NumericLiteral | BinaryExpression | UnaryExpression`,
|
||||
`export function valueToNode(value: RegExp): RegExpLiteral`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function valueToNode(value: ReadonlyArray<undefined | boolean | null | string | number | RegExp | object>): ArrayExpression`,
|
||||
// this throws with objects that are not PlainObject according to lodash,
|
||||
// or if there are non-valueToNode-able values
|
||||
`export function valueToNode(value: object): ObjectExpression`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function valueToNode(value: undefined | boolean | null | string | number | RegExp | object): Expression`,
|
||||
|
||||
// modifications/
|
||||
// eslint-disable-next-line max-len
|
||||
`export function removeTypeDuplicates(types: ReadonlyArray<FlowType | false | null | undefined>): FlowType[]`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function appendToMemberExpression<T extends Pick<MemberExpression, 'object' | 'property'>>(member: T, append: MemberExpression['property'], computed?: boolean): T`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function inherits<T extends Node | null | undefined>(child: T, parent: Node | null | undefined): T`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function prependToMemberExpression<T extends Pick<MemberExpression, 'object' | 'property'>>(member: T, prepend: MemberExpression['object']): T`,
|
||||
`export function removeProperties(
|
||||
n: Node,
|
||||
opts?: { preserveComments: boolean } | null
|
||||
): void;`,
|
||||
`export function removePropertiesDeep<T extends Node>(
|
||||
n: T,
|
||||
opts?: { preserveComments: boolean } | null
|
||||
): T;`,
|
||||
|
||||
// retrievers/
|
||||
// eslint-disable-next-line max-len
|
||||
`export function getBindingIdentifiers(node: Node, duplicates: true, outerOnly?: boolean): Record<string, Array<Identifier>>`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function getBindingIdentifiers(node: Node, duplicates?: false, outerOnly?: boolean): Record<string, Identifier>`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function getBindingIdentifiers(node: Node, duplicates: boolean, outerOnly?: boolean): Record<string, Identifier | Array<Identifier>>`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function getOuterBindingIdentifiers(node: Node, duplicates: true): Record<string, Array<Identifier>>`,
|
||||
`export function getOuterBindingIdentifiers(node: Node, duplicates?: false): Record<string, Identifier>`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function getOuterBindingIdentifiers(node: Node, duplicates: boolean): Record<string, Identifier | Array<Identifier>>`,
|
||||
|
||||
// traverse/
|
||||
`export type TraversalAncestors = ReadonlyArray<{
|
||||
node: Node,
|
||||
key: string,
|
||||
index?: number,
|
||||
}>;
|
||||
export type TraversalHandler<T> = (
|
||||
this: undefined, node: Node, parent: TraversalAncestors, type: T
|
||||
) => void;
|
||||
export type TraversalHandlers<T> = {
|
||||
enter?: TraversalHandler<T>,
|
||||
exit?: TraversalHandler<T>,
|
||||
};`.replace(/(^|\n) {2}/g, "$1"),
|
||||
// eslint-disable-next-line
|
||||
`export function traverse<T>(n: Node, h: TraversalHandler<T> | TraversalHandlers<T>, state?: T): void;`,
|
||||
`export function traverseFast<T>(n: Node, h: TraversalHandler<T>, state?: T): void;`,
|
||||
|
||||
// utils/
|
||||
// cleanJSXElementLiteralChild is not exported
|
||||
// inherit is not exported
|
||||
`export function shallowEqual<T extends object>(actual: object, expected: T): actual is T`,
|
||||
|
||||
// validators/
|
||||
// eslint-disable-next-line max-len
|
||||
`export function buildMatchMemberExpression(match: string, allowPartial?: boolean): (node: Node | null | undefined) => node is MemberExpression`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function is<T extends Node['type']>(type: T, n: Node | null | undefined, required?: undefined): n is Extract<Node, { type: T }>`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function is<T extends Node['type'], P extends Extract<Node, { type: T }>>(type: T, n: Node | null | undefined, required: Partial<P>): n is P`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function is<P extends Node>(type: string, n: Node | null | undefined, required: Partial<P>): n is P`,
|
||||
`export function is(type: string, n: Node | null | undefined, required?: Partial<Node>): n is Node`,
|
||||
`export function isBinding(node: Node, parent: Node, grandparent?: Node): boolean`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function isBlockScoped(node: Node): node is FunctionDeclaration | ClassDeclaration | VariableDeclaration`,
|
||||
`export function isImmutable(node: Node): node is Immutable`,
|
||||
`export function isLet(node: Node): node is VariableDeclaration`,
|
||||
`export function isNode(node: object | null | undefined): node is Node`,
|
||||
`export function isNodesEquivalent<T extends Partial<Node>>(a: T, b: any): b is T`,
|
||||
`export function isNodesEquivalent(a: any, b: any): boolean`,
|
||||
`export function isPlaceholderType(placeholderType: Node['type'], targetType: Node['type']): boolean`,
|
||||
`export function isReferenced(node: Node, parent: Node, grandparent?: Node): boolean`,
|
||||
`export function isScope(node: Node, parent: Node): node is Scopable`,
|
||||
`export function isSpecifierDefault(specifier: ModuleSpecifier): boolean`,
|
||||
`export function isType<T extends Node['type']>(nodetype: string, targetType: T): nodetype is T`,
|
||||
`export function isType(nodetype: string | null | undefined, targetType: string): boolean`,
|
||||
`export function isValidES3Identifier(name: string): boolean`,
|
||||
`export function isValidIdentifier(name: string): boolean`,
|
||||
`export function isVar(node: Node): node is VariableDeclaration`,
|
||||
// the MemberExpression implication is incidental, but it follows from the implementation
|
||||
// eslint-disable-next-line max-len
|
||||
`export function matchesPattern(node: Node | null | undefined, match: string | ReadonlyArray<string>, allowPartial?: boolean): node is MemberExpression`,
|
||||
// eslint-disable-next-line max-len
|
||||
`export function validate<T extends Node, K extends keyof T>(n: Node | null | undefined, key: K, value: T[K]): void;`,
|
||||
`export function validate(n: Node, key: string, value: any): void;`
|
||||
);
|
||||
|
||||
for (const type in t.DEPRECATED_KEYS) {
|
||||
code += `/**
|
||||
* @deprecated Use \`${t.DEPRECATED_KEYS[type]}\`
|
||||
*/
|
||||
export type ${type} = ${t.DEPRECATED_KEYS[type]};\n
|
||||
`;
|
||||
}
|
||||
|
||||
for (const type in t.FLIPPED_ALIAS_KEYS) {
|
||||
const types = t.FLIPPED_ALIAS_KEYS[type];
|
||||
code += `export type ${type} = ${types
|
||||
.map(type => `${type}`)
|
||||
.join(" | ")};\n`;
|
||||
}
|
||||
code += "\n";
|
||||
|
||||
code += "export interface Aliases {\n";
|
||||
for (const type in t.FLIPPED_ALIAS_KEYS) {
|
||||
code += ` ${type}: ${type};\n`;
|
||||
}
|
||||
code += "}\n\n";
|
||||
|
||||
code += lines.join("\n") + "\n";
|
||||
|
||||
//
|
||||
|
||||
process.stdout.write(code);
|
||||
|
||||
//
|
||||
|
||||
function areAllRemainingFieldsNullable(fieldName, fieldNames, fields) {
|
||||
const index = fieldNames.indexOf(fieldName);
|
||||
return fieldNames.slice(index).every(_ => isNullable(fields[_]));
|
||||
}
|
||||
|
||||
function hasDefault(field) {
|
||||
return field.default != null;
|
||||
}
|
||||
|
||||
function isNullable(field) {
|
||||
return field.optional || hasDefault(field);
|
||||
}
|
||||
|
||||
function sortFieldNames(fields, type) {
|
||||
return fields.sort((fieldA, fieldB) => {
|
||||
const indexA = t.BUILDER_KEYS[type].indexOf(fieldA);
|
||||
const indexB = t.BUILDER_KEYS[type].indexOf(fieldB);
|
||||
if (indexA === indexB) return fieldA < fieldB ? -1 : 1;
|
||||
if (indexA === -1) return 1;
|
||||
if (indexB === -1) return -1;
|
||||
return indexA - indexB;
|
||||
});
|
||||
}
|
||||
Generated
Vendored
-91
@@ -1,91 +0,0 @@
|
||||
import {
|
||||
DEPRECATED_KEYS,
|
||||
FLIPPED_ALIAS_KEYS,
|
||||
NODE_FIELDS,
|
||||
PLACEHOLDERS,
|
||||
PLACEHOLDERS_FLIPPED_ALIAS,
|
||||
VISITOR_KEYS,
|
||||
} from "../../lib/index.js";
|
||||
|
||||
const has = Function.call.bind(Object.prototype.hasOwnProperty);
|
||||
|
||||
function joinComparisons(leftArr, right) {
|
||||
return (
|
||||
leftArr.map(JSON.stringify).join(` === ${right} || `) + ` === ${right}`
|
||||
);
|
||||
}
|
||||
|
||||
function addIsHelper(type, aliasKeys, deprecated) {
|
||||
const targetType = JSON.stringify(type);
|
||||
let aliasSource = "";
|
||||
if (aliasKeys) {
|
||||
aliasSource = joinComparisons(aliasKeys, "nodeType");
|
||||
}
|
||||
|
||||
let placeholderSource = "";
|
||||
const placeholderTypes = [];
|
||||
if (PLACEHOLDERS.includes(type) && has(FLIPPED_ALIAS_KEYS, type)) {
|
||||
placeholderTypes.push(type);
|
||||
}
|
||||
if (has(PLACEHOLDERS_FLIPPED_ALIAS, type)) {
|
||||
placeholderTypes.push(...PLACEHOLDERS_FLIPPED_ALIAS[type]);
|
||||
}
|
||||
if (placeholderTypes.length > 0) {
|
||||
placeholderSource =
|
||||
' || nodeType === "Placeholder" && (' +
|
||||
joinComparisons(
|
||||
placeholderTypes,
|
||||
"(node as t.Placeholder).expectedNode"
|
||||
) +
|
||||
")";
|
||||
}
|
||||
|
||||
const result =
|
||||
NODE_FIELDS[type] || FLIPPED_ALIAS_KEYS[type]
|
||||
? `node is t.${type}`
|
||||
: "boolean";
|
||||
|
||||
return `export function is${type}(node: object | null | undefined, opts?: object | null): ${result} {
|
||||
${deprecated || ""}
|
||||
if (!node) return false;
|
||||
|
||||
const nodeType = (node as t.Node).type;
|
||||
if (${
|
||||
aliasSource ? aliasSource : `nodeType === ${targetType}`
|
||||
}${placeholderSource}) {
|
||||
if (typeof opts === "undefined") {
|
||||
return true;
|
||||
} else {
|
||||
return shallowEqual(node, opts);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
export default function generateValidators() {
|
||||
let output = `/*
|
||||
* This file is auto-generated! Do not modify it directly.
|
||||
* To re-generate run 'make build'
|
||||
*/
|
||||
import shallowEqual from "../../utils/shallowEqual";
|
||||
import type * as t from "../..";\n\n`;
|
||||
|
||||
Object.keys(VISITOR_KEYS).forEach(type => {
|
||||
output += addIsHelper(type);
|
||||
});
|
||||
|
||||
Object.keys(FLIPPED_ALIAS_KEYS).forEach(type => {
|
||||
output += addIsHelper(type, FLIPPED_ALIAS_KEYS[type]);
|
||||
});
|
||||
|
||||
Object.keys(DEPRECATED_KEYS).forEach(type => {
|
||||
const newType = DEPRECATED_KEYS[type];
|
||||
const deprecated = `console.trace("The node type ${type} has been renamed to ${newType}");`;
|
||||
output += addIsHelper(type, null, deprecated);
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
{ "type": "module" }
|
||||
Generated
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
const toLowerCase = Function.call.bind("".toLowerCase);
|
||||
|
||||
export default function formatBuilderName(type) {
|
||||
// FunctionExpression -> functionExpression
|
||||
// JSXIdentifier -> jsxIdentifier
|
||||
// V8IntrinsicIdentifier -> v8IntrinsicIdentifier
|
||||
return type.replace(/^([A-Z](?=[a-z0-9])|[A-Z]+(?=[A-Z]))/, toLowerCase);
|
||||
}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
export default function lowerFirst(string) {
|
||||
return string[0].toLowerCase() + string.slice(1);
|
||||
}
|
||||
Generated
Vendored
-69
@@ -1,69 +0,0 @@
|
||||
export default function stringifyValidator(validator, nodePrefix) {
|
||||
if (validator === undefined) {
|
||||
return "any";
|
||||
}
|
||||
|
||||
if (validator.each) {
|
||||
return `Array<${stringifyValidator(validator.each, nodePrefix)}>`;
|
||||
}
|
||||
|
||||
if (validator.chainOf) {
|
||||
const ret = stringifyValidator(validator.chainOf[1], nodePrefix);
|
||||
return Array.isArray(ret) && ret.length === 1 && ret[0] === "any"
|
||||
? stringifyValidator(validator.chainOf[0], nodePrefix)
|
||||
: ret;
|
||||
}
|
||||
|
||||
if (validator.oneOf) {
|
||||
return validator.oneOf.map(JSON.stringify).join(" | ");
|
||||
}
|
||||
|
||||
if (validator.oneOfNodeTypes) {
|
||||
return validator.oneOfNodeTypes.map(_ => nodePrefix + _).join(" | ");
|
||||
}
|
||||
|
||||
if (validator.oneOfNodeOrValueTypes) {
|
||||
return validator.oneOfNodeOrValueTypes
|
||||
.map(_ => {
|
||||
return isValueType(_) ? _ : nodePrefix + _;
|
||||
})
|
||||
.join(" | ");
|
||||
}
|
||||
|
||||
if (validator.type) {
|
||||
return validator.type;
|
||||
}
|
||||
|
||||
if (validator.shapeOf) {
|
||||
return (
|
||||
"{ " +
|
||||
Object.keys(validator.shapeOf)
|
||||
.map(shapeKey => {
|
||||
const propertyDefinition = validator.shapeOf[shapeKey];
|
||||
if (propertyDefinition.validate) {
|
||||
const isOptional =
|
||||
propertyDefinition.optional || propertyDefinition.default != null;
|
||||
return (
|
||||
shapeKey +
|
||||
(isOptional ? "?: " : ": ") +
|
||||
stringifyValidator(propertyDefinition.validate)
|
||||
);
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join(", ") +
|
||||
" }"
|
||||
);
|
||||
}
|
||||
|
||||
return ["any"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Heuristic to decide whether or not the given type is a value type (eg. "null")
|
||||
* or a Node type (eg. "Expression").
|
||||
*/
|
||||
export function isValueType(type) {
|
||||
return type.charAt(0).toLowerCase() === type.charAt(0);
|
||||
}
|
||||
Generated
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
export default function toFunctionName(typeName) {
|
||||
const _ = typeName.replace(/^TS/, "ts").replace(/^JSX/, "jsx");
|
||||
return _.slice(0, 1).toLowerCase() + _.slice(1);
|
||||
}
|
||||
+9
-12
@@ -1,15 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var jsdocTypePrattParser = require('jsdoc-type-pratt-parser');
|
||||
var esquery = require('esquery');
|
||||
var commentParser = require('comment-parser');
|
||||
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
var esquery__default = /*#__PURE__*/_interopDefaultLegacy(esquery);
|
||||
|
||||
/**
|
||||
* Removes initial and ending brackets from `rawType`
|
||||
* @param {JsdocTypeLine[]|JsdocTag} container
|
||||
@@ -280,7 +274,10 @@ const commentParserToESTree = (jsdoc, mode, {
|
||||
initial,
|
||||
type: 'JsdocDescriptionLine'
|
||||
});
|
||||
holder.description += holder.description ? '\n' + description : description;
|
||||
|
||||
if (!tag) {
|
||||
holder.description += idx <= 1 && !lastTag ? description : '\n' + description;
|
||||
}
|
||||
} // Clean-up where last line itself has tag content
|
||||
|
||||
|
||||
@@ -321,9 +318,9 @@ const commentHandler = settings => {
|
||||
const {
|
||||
mode
|
||||
} = settings;
|
||||
const selector = esquery__default["default"].parse(commentSelector);
|
||||
const selector = esquery.parse(commentSelector);
|
||||
const ast = commentParserToESTree(jsdoc, mode);
|
||||
return esquery__default["default"].matches(ast, selector, null, {
|
||||
return esquery.matches(ast, selector, null, {
|
||||
visitorKeys: { ...jsdocTypePrattParser.visitorKeys,
|
||||
...jsdocVisitorKeys
|
||||
}
|
||||
@@ -351,8 +348,8 @@ const {
|
||||
const hasSeeWithLink = spec => {
|
||||
return spec.tag === 'see' && /\{@link.+?\}/u.test(spec.source[0].source);
|
||||
};
|
||||
const defaultNoTypes = ['default', 'defaultvalue', 'see'];
|
||||
const defaultNoNames = ['access', 'author', 'default', 'defaultvalue', 'description', 'example', 'exception', 'kind', 'license', 'return', 'returns', 'since', 'summary', 'throws', 'version', 'variation'];
|
||||
const defaultNoTypes = ['default', 'defaultvalue', 'description', 'example', 'file', 'fileoverview', 'license', 'overview', 'see', 'summary'];
|
||||
const defaultNoNames = ['access', 'author', 'default', 'defaultvalue', 'description', 'example', 'exception', 'file', 'fileoverview', 'kind', 'license', 'overview', 'return', 'returns', 'since', 'summary', 'throws', 'version', 'variation'];
|
||||
const optionalBrackets = /^\[(?<name>[^=]*)=[^\]]*\]/u;
|
||||
const preserveTypeTokenizer = typeTokenizer('preserve');
|
||||
const preserveDescriptionTokenizer = descriptionTokenizer('preserve');
|
||||
@@ -553,7 +550,7 @@ const getTSFunctionComment = function (astNode) {
|
||||
};
|
||||
|
||||
const invokedExpression = new Set(['CallExpression', 'OptionalCallExpression', 'NewExpression']);
|
||||
const allowableCommentNode = new Set(['VariableDeclaration', 'ExpressionStatement', 'MethodDefinition', 'Property', 'ObjectProperty', 'ClassProperty', 'PropertyDefinition', 'ExportDefaultDeclaration']);
|
||||
const allowableCommentNode = new Set(['AssignmentPattern', 'VariableDeclaration', 'ExpressionStatement', 'MethodDefinition', 'Property', 'ObjectProperty', 'ClassProperty', 'PropertyDefinition', 'ExportDefaultDeclaration']);
|
||||
/**
|
||||
* Reduces the provided node to the appropriate node for evaluating
|
||||
* JSDoc comment status.
|
||||
|
||||
+19
-20
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@es-joy/jsdoccomment",
|
||||
"version": "0.31.0",
|
||||
"version": "0.33.4",
|
||||
"author": "Brett Zamir <brettz9@yahoo.com>",
|
||||
"contributors": [],
|
||||
"description": "Maintained replacement for ESLint's deprecated SourceCode#getJSDocComment along with other jsdoc utilities",
|
||||
@@ -38,7 +38,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/es-joy/jsdoccomment",
|
||||
"engines": {
|
||||
"node": "^14 || ^16 || ^17 || ^18"
|
||||
"node": "^14 || ^16 || ^17 || ^18 || ^19"
|
||||
},
|
||||
"dependencies": {
|
||||
"comment-parser": "1.3.1",
|
||||
@@ -46,33 +46,33 @@
|
||||
"jsdoc-type-pratt-parser": "~3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.17.12",
|
||||
"@babel/core": "^7.19.3",
|
||||
"@babel/plugin-syntax-class-properties": "^7.12.13",
|
||||
"@babel/preset-env": "^7.17.12",
|
||||
"@babel/preset-env": "^7.19.4",
|
||||
"@brettz9/eslint-plugin": "^1.0.4",
|
||||
"@rollup/plugin-babel": "^5.3.1",
|
||||
"c8": "^7.11.3",
|
||||
"@rollup/plugin-babel": "^6.0.0",
|
||||
"c8": "^7.12.0",
|
||||
"chai": "^4.3.6",
|
||||
"eslint": "^8.15.0",
|
||||
"eslint-config-ash-nazg": "33.1.0",
|
||||
"eslint": "^8.25.0",
|
||||
"eslint-config-ash-nazg": "34.3.0",
|
||||
"eslint-config-standard": "^17.0.0",
|
||||
"eslint-plugin-array-func": "^3.1.7",
|
||||
"eslint-plugin-compat": "^4.0.2",
|
||||
"eslint-plugin-eslint-comments": "^3.2.0",
|
||||
"eslint-plugin-html": "^6.2.0",
|
||||
"eslint-plugin-html": "^7.1.0",
|
||||
"eslint-plugin-import": "^2.26.0",
|
||||
"eslint-plugin-jsdoc": "^39.2.9",
|
||||
"eslint-plugin-markdown": "^2.2.1",
|
||||
"eslint-plugin-n": "^15.2.0",
|
||||
"eslint-plugin-jsdoc": "^39.3.13",
|
||||
"eslint-plugin-markdown": "^3.0.0",
|
||||
"eslint-plugin-n": "^15.3.0",
|
||||
"eslint-plugin-no-unsanitized": "^4.0.1",
|
||||
"eslint-plugin-no-use-extend-native": "^0.5.0",
|
||||
"eslint-plugin-promise": "^6.0.0",
|
||||
"eslint-plugin-sonarjs": "^0.13.0",
|
||||
"eslint-plugin-unicorn": "^42.0.0",
|
||||
"espree": "^9.3.2",
|
||||
"eslint-plugin-promise": "^6.1.0",
|
||||
"eslint-plugin-sonarjs": "^0.16.0",
|
||||
"eslint-plugin-unicorn": "^44.0.2",
|
||||
"espree": "^9.4.0",
|
||||
"estraverse": "^5.3.0",
|
||||
"mocha": "^10.0.0",
|
||||
"rollup": "^2.74.0"
|
||||
"mocha": "^10.1.0",
|
||||
"rollup": "^3.2.3"
|
||||
},
|
||||
"scripts": {
|
||||
"open": "open ./coverage/lcov-report/index.html",
|
||||
@@ -82,6 +82,5 @@
|
||||
"mocha": "mocha --require chai/register-expect.js",
|
||||
"c8": "c8 npm run mocha",
|
||||
"test": "npm run lint && npm run rollup && npm run c8"
|
||||
},
|
||||
"readme": "# @es-joy/jsdoccomment\n\n[](https://github.com/brettz9/getJSDocComment/actions)\n\nThis project aims to preserve and expand upon the\n`SourceCode#getJSDocComment` functionality of the deprecated ESLint method.\n\nIt also exports a number of functions currently for working with JSDoc:\n\n## API\n\n### `parseComment`\n\nFor parsing `comment-parser` in a JSDoc-specific manner.\nMight wish to have tags with or without tags, etc. derived from a split off\nJSON file.\n\n### `commentParserToESTree`\n\nConverts [comment-parser](https://github.com/syavorsky/comment-parser)\nAST to ESTree/ESLint/Babel friendly AST. See the \"ESLint AST...\" section below.\n\n### `estreeToString`\n\nStringifies. In addition to the node argument, it accepts an optional second\noptions object with a single `preferRawType` key. If you don't need to modify\nJSDoc type AST, you might wish to set this to `true` to get the benefits of\npreserving the raw form, but for AST-based stringification of JSDoc types,\nkeep it `false` (the default).\n\n### `jsdocVisitorKeys`\n\nThe [VisitorKeys](https://github.com/eslint/eslint-visitor-keys)\nfor `JsdocBlock`, `JsdocDescriptionLine`, and `JsdocTag`. More likely to be\nsubject to change or dropped in favor of another type parser.\n\n### `jsdocTypeVisitorKeys`\n\nJust a re-export of [VisitorKeys](https://github.com/eslint/eslint-visitor-keys)\nfrom [`jsdoc-type-pratt-parser`](https://github.com/simonseyock/jsdoc-type-pratt-parser/).\n\n### `getDefaultTagStructureForMode`\n\nProvides info on JSDoc tags:\n\n- `nameContents` ('namepath-referencing'|'namepath-defining'|\n 'dual-namepath-referencing'|false) - Whether and how a name is allowed\n following any type. Tags without a proper name (value `false`) may still\n have a description (which can appear like a name); `descriptionAllowed`\n in such cases would be `true`.\n The presence of a truthy `nameContents` value is therefore only intended\n to signify whether separate parsing should occur for a name vs. a\n description, and what its nature should be.\n- `nameRequired` (boolean) - Whether a name must be present following any type.\n- `descriptionAllowed` (boolean) - Whether a description (following any name)\n is allowed.\n- `typeAllowed` (boolean) - Whether the tag accepts a curly bracketed portion.\n Even without a type, a tag may still have a name and/or description.\n- `typeRequired` (boolean) - Whether a curly bracketed type must be present.\n- `typeOrNameRequired` (boolean) - Whether either a curly bracketed type is\n required or a name, but not necessarily both.\n\n### Miscellaneous\n\nAlso currently exports these utilities, though they might be removed in the\nfuture:\n\n- `getTokenizers` - Used with `parseComment` (its main core)\n- `toCamelCase` - Convert to CamelCase.\n- `hasSeeWithLink` - A utility to detect if a tag is `@see` and has a `@link`\n- `commentHandler` - Used by `eslint-plugin-jsdoc`. Might be removed in future.\n- `commentParserToESTree`- Converts [comment-parser](https://github.com/syavorsky/comment-parser)\n AST to ESTree/ESLint/Babel friendly AST\n- `jsdocVisitorKeys` - The [VisitorKeys](https://github.com/eslint/eslint-visitor-keys)\n for `JSDocBlock`, `JSDocDescriptionLine`, and `JSDocTag`. Might change.\n- `jsdocTypeVisitorKeys` - [VisitorKeys](https://github.com/eslint/eslint-visitor-keys)\n for `jsdoc-type-pratt-parser`.\n- `getTokenizers` - A utility. Might be removed in future.\n- `toCamelCase` - A utility. Might be removed in future.\n- `hasSeeWithLink` - A utility to detect if a tag is `@see` and has a `@link`\n- `defaultNoTypes` = The tags which allow no types by default:\n `default`, `defaultvalue`, `see`;\n- `defaultNoNames` - The tags which allow no names by default:\n `access`, `author`, `default`, `defaultvalue`, `description`, `example`,\n `exception`, `kind`, `license`, `return`, `returns`, `since`, `summary`,\n `throws`, `version`, `variation`\n\n## ESLint AST produced for `comment-parser` nodes (`JsdocBlock`, `JsdocTag`, and `JsdocDescriptionLine`)\n\nNote: Although not added in this package, `@es-joy/jsdoc-eslint-parser` adds\na `jsdoc` property to other ES nodes (using this project's `getJSDocComment`\nto determine the specific comment-block that will be attached as AST).\n\n### `JsdocBlock`\n\nHas two visitable properties:\n\n1. `tags` (an array of `JsdocTag`; see below)\n2. `descriptionLines` (an array of `JsdocDescriptionLine` for multiline\n descriptions).\n\nHas the following custom non-visitable property:\n\n1. `lastDescriptionLine` - A number\n2. `endLine` - A number representing the line number with `end`/`terminal`\n\nMay also have the following non-visitable properties from `comment-parser`:\n\n1. `description` - Same as `descriptionLines` but as a string with newlines.\n2. `delimiter`\n3. `postDelimiter`\n4. `lineEnd`\n5. `initialLine truncated
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+6
-3
@@ -282,9 +282,12 @@ const commentParserToESTree = (jsdoc, mode, {
|
||||
type: 'JsdocDescriptionLine'
|
||||
}
|
||||
);
|
||||
holder.description += holder.description
|
||||
? '\n' + description
|
||||
: description;
|
||||
|
||||
if (!tag) {
|
||||
holder.description += idx <= 1 && !lastTag
|
||||
? description
|
||||
: '\n' + description;
|
||||
}
|
||||
}
|
||||
|
||||
// Clean-up where last line itself has tag content
|
||||
|
||||
+1
@@ -119,6 +119,7 @@ const invokedExpression = new Set(
|
||||
['CallExpression', 'OptionalCallExpression', 'NewExpression']
|
||||
);
|
||||
const allowableCommentNode = new Set([
|
||||
'AssignmentPattern',
|
||||
'VariableDeclaration',
|
||||
'ExpressionStatement',
|
||||
'MethodDefinition',
|
||||
|
||||
+8
-3
@@ -15,14 +15,19 @@ export const hasSeeWithLink = (spec) => {
|
||||
return spec.tag === 'see' && (/\{@link.+?\}/u).test(spec.source[0].source);
|
||||
};
|
||||
|
||||
export const defaultNoTypes = ['default', 'defaultvalue', 'see'];
|
||||
export const defaultNoTypes = [
|
||||
'default', 'defaultvalue', 'description', 'example',
|
||||
'file', 'fileoverview', 'license',
|
||||
'overview', 'see', 'summary'
|
||||
];
|
||||
|
||||
export const defaultNoNames = [
|
||||
'access', 'author',
|
||||
'default', 'defaultvalue',
|
||||
'description',
|
||||
'example', 'exception', 'kind',
|
||||
'license',
|
||||
'example', 'exception', 'file', 'fileoverview',
|
||||
'kind',
|
||||
'license', 'overview',
|
||||
'return', 'returns',
|
||||
'since', 'summary',
|
||||
'throws',
|
||||
|
||||
+199
-51
@@ -124,6 +124,18 @@ function isString(value) {
|
||||
return typeof value === 'string';
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the files key of a config object is a nonempty array.
|
||||
* @param {object} config The config object to check.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the files key isn't a nonempty array.
|
||||
*/
|
||||
function assertNonEmptyFilesArray(config) {
|
||||
if (!Array.isArray(config.files) || config.files.length === 0) {
|
||||
throw new TypeError('The files key must be a non-empty array.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper around minimatch that caches minimatch patterns for
|
||||
* faster matching speed over multiple file path evaluations.
|
||||
@@ -132,7 +144,7 @@ function isString(value) {
|
||||
* @param {object} options The minimatch options to use.
|
||||
* @returns
|
||||
*/
|
||||
function doMatch(filepath, pattern, options) {
|
||||
function doMatch(filepath, pattern, options = {}) {
|
||||
|
||||
let cache = minimatchCache;
|
||||
|
||||
@@ -143,7 +155,7 @@ function doMatch(filepath, pattern, options) {
|
||||
let matcher = cache.get(pattern);
|
||||
|
||||
if (!matcher) {
|
||||
matcher = new Minimatch(pattern, options);
|
||||
matcher = new Minimatch(pattern, Object.assign({}, MINIMATCH_OPTIONS, options));
|
||||
cache.set(pattern, matcher);
|
||||
}
|
||||
|
||||
@@ -260,51 +272,42 @@ function normalizeSync(items, context, extraConfigTypes) {
|
||||
* @param {string} relativeFilePath The relative path of the file to check.
|
||||
* @returns {boolean} True if the path should be ignored and false if not.
|
||||
*/
|
||||
function shouldIgnoreFilePath(ignores, filePath, relativeFilePath) {
|
||||
function shouldIgnorePath(ignores, filePath, relativeFilePath) {
|
||||
|
||||
// all files outside of the basePath are ignored
|
||||
if (relativeFilePath.startsWith('..')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let shouldIgnore = false;
|
||||
return ignores.reduce((ignored, matcher) => {
|
||||
|
||||
for (const matcher of ignores) {
|
||||
if (!ignored) {
|
||||
|
||||
if (typeof matcher === 'function') {
|
||||
shouldIgnore = shouldIgnore || matcher(filePath);
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* If there's a negated pattern, that means anything matching
|
||||
* must NOT be ignored. To do that, we need to use the `flipNegate`
|
||||
* option for minimatch to check if the filepath matches the
|
||||
* pattern specified after the !, and if that result is true,
|
||||
* then we return false immediately because this file should
|
||||
* never be ignored.
|
||||
*/
|
||||
if (matcher.startsWith('!')) {
|
||||
|
||||
/*
|
||||
* The file must already be ignored in order to apply a negated
|
||||
* pattern, because negated patterns simply remove files that
|
||||
* would already be ignored.
|
||||
*/
|
||||
if (shouldIgnore &&
|
||||
doMatch(relativeFilePath, matcher, {
|
||||
...MINIMATCH_OPTIONS,
|
||||
flipNegate: true
|
||||
})) {
|
||||
return false;
|
||||
if (typeof matcher === 'function') {
|
||||
return matcher(filePath);
|
||||
}
|
||||
} else {
|
||||
shouldIgnore = shouldIgnore || doMatch(relativeFilePath, matcher, MINIMATCH_OPTIONS);
|
||||
|
||||
// don't check negated patterns because we're not ignored yet
|
||||
if (!matcher.startsWith('!')) {
|
||||
return doMatch(relativeFilePath, matcher);
|
||||
}
|
||||
|
||||
// otherwise we're still not ignored
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// only need to check negated patterns because we're ignored
|
||||
if (typeof matcher === 'string' && matcher.startsWith('!')) {
|
||||
return !doMatch(relativeFilePath, matcher, {
|
||||
flipNegate: true
|
||||
});
|
||||
}
|
||||
|
||||
return ignored;
|
||||
|
||||
}, false);
|
||||
|
||||
return shouldIgnore;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,15 +330,13 @@ function pathMatches(filePath, basePath, config) {
|
||||
const relativeFilePath = path.relative(basePath, filePath);
|
||||
|
||||
// if files isn't an array, throw an error
|
||||
if (!Array.isArray(config.files) || config.files.length === 0) {
|
||||
throw new TypeError('The files key must be a non-empty array.');
|
||||
}
|
||||
assertNonEmptyFilesArray(config);
|
||||
|
||||
// match both strings and functions
|
||||
const match = pattern => {
|
||||
|
||||
if (isString(pattern)) {
|
||||
return doMatch(relativeFilePath, pattern, MINIMATCH_OPTIONS);
|
||||
return doMatch(relativeFilePath, pattern);
|
||||
}
|
||||
|
||||
if (typeof pattern === 'function') {
|
||||
@@ -359,7 +360,7 @@ function pathMatches(filePath, basePath, config) {
|
||||
* if there are any files to ignore.
|
||||
*/
|
||||
if (filePathMatchesPattern && config.ignores) {
|
||||
filePathMatchesPattern = !shouldIgnoreFilePath(config.ignores, filePath, relativeFilePath);
|
||||
filePathMatchesPattern = !shouldIgnorePath(config.ignores, filePath, relativeFilePath);
|
||||
}
|
||||
|
||||
return filePathMatchesPattern;
|
||||
@@ -429,11 +430,11 @@ class ConfigArray extends Array {
|
||||
* @param {Array<string>} [options.configTypes] List of config types supported.
|
||||
*/
|
||||
constructor(configs, {
|
||||
basePath = '',
|
||||
normalized = false,
|
||||
schema: customSchema,
|
||||
extraConfigTypes = []
|
||||
} = {}
|
||||
basePath = '',
|
||||
normalized = false,
|
||||
schema: customSchema,
|
||||
extraConfigTypes = []
|
||||
} = {}
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -482,7 +483,10 @@ class ConfigArray extends Array {
|
||||
|
||||
// init cache
|
||||
dataCache.set(this, {
|
||||
explicitMatches: new Map()
|
||||
explicitMatches: new Map(),
|
||||
directoryMatches: new Map(),
|
||||
files: undefined,
|
||||
ignores: undefined
|
||||
});
|
||||
|
||||
// load the configs into this array
|
||||
@@ -572,7 +576,38 @@ class ConfigArray extends Array {
|
||||
* are additional keys, then ignores act like exclusions.
|
||||
*/
|
||||
if (config.ignores && Object.keys(config).length === 1) {
|
||||
result.push(...config.ignores);
|
||||
|
||||
/*
|
||||
* If there are directory ignores, then we need to double up
|
||||
* the patterns to be ignored. For instance, `foo` will also
|
||||
* need `foo/**` in order to account for subdirectories.
|
||||
*/
|
||||
config.ignores.forEach(ignore => {
|
||||
|
||||
result.push(ignore);
|
||||
|
||||
if (typeof ignore === 'string') {
|
||||
|
||||
// unignoring files won't work unless we unignore directories too
|
||||
if (ignore.startsWith('!')) {
|
||||
|
||||
if (ignore.endsWith('/**')) {
|
||||
result.push(ignore.slice(0, ignore.length - 3));
|
||||
} else if (ignore.endsWith('/*')) {
|
||||
result.push(ignore.slice(0, ignore.length - 2));
|
||||
}
|
||||
}
|
||||
|
||||
// directories should work with or without a trailing slash
|
||||
if (ignore.endsWith('/')) {
|
||||
result.push(ignore.slice(0, ignore.length - 1));
|
||||
result.push(ignore + '**');
|
||||
} else if (!ignore.endsWith('*')) {
|
||||
result.push(ignore + '/**');
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -680,7 +715,7 @@ class ConfigArray extends Array {
|
||||
// TODO: Maybe move elsewhere? Maybe combine with getConfig() logic?
|
||||
const relativeFilePath = path.relative(this.basePath, filePath);
|
||||
|
||||
if (shouldIgnoreFilePath(this.ignores, filePath, relativeFilePath)) {
|
||||
if (shouldIgnorePath(this.ignores, filePath, relativeFilePath)) {
|
||||
debug(`Ignoring ${filePath}`);
|
||||
|
||||
// cache and return result
|
||||
@@ -726,11 +761,20 @@ class ConfigArray extends Array {
|
||||
|
||||
// next check to see if the file should be ignored
|
||||
|
||||
// check if this should be ignored due to its directory
|
||||
if (this.isDirectoryIgnored(path.dirname(filePath))) {
|
||||
debug(`Ignoring ${filePath} based on directory pattern`);
|
||||
|
||||
// cache and return result - finalConfig is undefined at this point
|
||||
cache.set(filePath, finalConfig);
|
||||
return finalConfig;
|
||||
}
|
||||
|
||||
// TODO: Maybe move elsewhere?
|
||||
const relativeFilePath = path.relative(this.basePath, filePath);
|
||||
|
||||
if (shouldIgnoreFilePath(this.ignores, filePath, relativeFilePath)) {
|
||||
debug(`Ignoring ${filePath}`);
|
||||
if (shouldIgnorePath(this.ignores, filePath, relativeFilePath)) {
|
||||
debug(`Ignoring ${filePath} based on file pattern`);
|
||||
|
||||
// cache and return result - finalConfig is undefined at this point
|
||||
cache.set(filePath, finalConfig);
|
||||
@@ -741,15 +785,70 @@ class ConfigArray extends Array {
|
||||
|
||||
const matchingConfigIndices = [];
|
||||
let matchFound = false;
|
||||
const universalPattern = /\/\*{1,2}$/;
|
||||
|
||||
this.forEach((config, index) => {
|
||||
|
||||
if (!config.files) {
|
||||
debug(`Universal config found for ${filePath}`);
|
||||
debug(`Anonymous universal config found for ${filePath}`);
|
||||
matchingConfigIndices.push(index);
|
||||
return;
|
||||
}
|
||||
|
||||
assertNonEmptyFilesArray(config);
|
||||
|
||||
/*
|
||||
* If a config has a files pattern ending in /** or /*, and the
|
||||
* filePath only matches those patterns, then the config is only
|
||||
* applied if there is another config where the filePath matches
|
||||
* a file with a specific extensions such as *.js.
|
||||
*/
|
||||
|
||||
const universalFiles = config.files.filter(
|
||||
pattern => universalPattern.test(pattern)
|
||||
);
|
||||
|
||||
// universal patterns were found so we need to check the config twice
|
||||
if (universalFiles.length) {
|
||||
|
||||
debug('Universal files patterns found. Checking carefully.');
|
||||
|
||||
const nonUniversalFiles = config.files.filter(
|
||||
pattern => !universalPattern.test(pattern)
|
||||
);
|
||||
|
||||
// check that the config matches without the non-universal files first
|
||||
if (
|
||||
nonUniversalFiles.length &&
|
||||
pathMatches(
|
||||
filePath, this.basePath,
|
||||
{ files: nonUniversalFiles, ignores: config.ignores }
|
||||
)
|
||||
) {
|
||||
debug(`Matching config found for ${filePath}`);
|
||||
matchingConfigIndices.push(index);
|
||||
matchFound = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// if there wasn't a match then check if it matches with universal files
|
||||
if (
|
||||
universalFiles.length &&
|
||||
pathMatches(
|
||||
filePath, this.basePath,
|
||||
{ files: universalFiles, ignores: config.ignores }
|
||||
)
|
||||
) {
|
||||
debug(`Matching config found for ${filePath}`);
|
||||
matchingConfigIndices.push(index);
|
||||
return;
|
||||
}
|
||||
|
||||
// if we make here, then there was no match
|
||||
return;
|
||||
}
|
||||
|
||||
// the normal case
|
||||
if (pathMatches(filePath, this.basePath, config)) {
|
||||
debug(`Matching config found for ${filePath}`);
|
||||
matchingConfigIndices.push(index);
|
||||
@@ -797,11 +896,60 @@ class ConfigArray extends Array {
|
||||
* Determines if the given filepath is ignored based on the configs.
|
||||
* @param {string} filePath The complete path of a file to check.
|
||||
* @returns {boolean} True if the path is ignored, false if not.
|
||||
* @deprecated Use `isFileIgnored` instead.
|
||||
*/
|
||||
isIgnored(filePath) {
|
||||
return this.isFileIgnored(filePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the given filepath is ignored based on the configs.
|
||||
* @param {string} filePath The complete path of a file to check.
|
||||
* @returns {boolean} True if the path is ignored, false if not.
|
||||
*/
|
||||
isFileIgnored(filePath) {
|
||||
return this.getConfig(filePath) === undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the given directory is ignored based on the configs.
|
||||
* This checks only default `ignores` that don't have `files` in the
|
||||
* same config. A pattern such as `/foo` be considered to ignore the directory
|
||||
* while a pattern such as `/foo/**` is not considered to ignore the
|
||||
* directory because it is matching files.
|
||||
* @param {string} directoryPath The complete path of a directory to check.
|
||||
* @returns {boolean} True if the directory is ignored, false if not. Will
|
||||
* return true for any directory that is not inside of `basePath`.
|
||||
* @throws {Error} When the `ConfigArray` is not normalized.
|
||||
*/
|
||||
isDirectoryIgnored(directoryPath) {
|
||||
|
||||
assertNormalized(this);
|
||||
|
||||
const relativeDirectoryPath = path.relative(this.basePath, directoryPath);
|
||||
if (relativeDirectoryPath.startsWith('..')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// first check the cache
|
||||
const cache = dataCache.get(this).directoryMatches;
|
||||
|
||||
if (cache.has(relativeDirectoryPath)) {
|
||||
return cache.get(relativeDirectoryPath);
|
||||
}
|
||||
|
||||
// first check non-/** paths
|
||||
const result = shouldIgnorePath(
|
||||
this.ignores, //.filter(matcher => typeof matcher === "function" || !matcher.endsWith("/**")),
|
||||
directoryPath,
|
||||
relativeDirectoryPath
|
||||
);
|
||||
|
||||
cache.set(relativeDirectoryPath, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.ConfigArray = ConfigArray;
|
||||
|
||||
+5
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@humanwhocodes/config-array",
|
||||
"version": "0.10.7",
|
||||
"version": "0.11.7",
|
||||
"description": "Glob-based configuration matching.",
|
||||
"author": "Nicholas C. Zakas",
|
||||
"main": "api.js",
|
||||
@@ -19,6 +19,7 @@
|
||||
"build": "rollup -c",
|
||||
"format": "nitpik",
|
||||
"lint": "eslint *.config.js src/*.js tests/*.js",
|
||||
"lint:fix": "eslint --fix *.config.js src/*.js tests/*.js",
|
||||
"prepublish": "npm run build",
|
||||
"test:coverage": "nyc --include src/*.js npm run test",
|
||||
"test": "mocha -r esm tests/ --recursive"
|
||||
@@ -43,13 +44,13 @@
|
||||
"dependencies": {
|
||||
"@humanwhocodes/object-schema": "^1.2.1",
|
||||
"debug": "^4.1.1",
|
||||
"minimatch": "^3.0.4"
|
||||
"minimatch": "^3.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nitpik/javascript": "0.4.0",
|
||||
"@nitpik/node": "0.0.5",
|
||||
"chai": "4.2.0",
|
||||
"eslint": "8.24.0",
|
||||
"chai": "4.3.6",
|
||||
"eslint": "8.26.0",
|
||||
"esm": "3.2.25",
|
||||
"lint-staged": "13.0.3",
|
||||
"mocha": "6.2.3",
|
||||
|
||||
Generated
Vendored
+19
-11
@@ -290,7 +290,6 @@ const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)';
|
||||
const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';
|
||||
const LEAST_UPPER_BOUND = -1;
|
||||
const GREATEST_LOWER_BOUND = 1;
|
||||
const ALL_BOUND = 0;
|
||||
/**
|
||||
* Returns the encoded (VLQ string) form of the SourceMap's mappings field.
|
||||
*/
|
||||
@@ -409,11 +408,12 @@ class TraceMap {
|
||||
const { names, resolvedSources } = map;
|
||||
return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
|
||||
};
|
||||
allGeneratedPositionsFor = (map, { source, line, column }) => {
|
||||
return generatedPosition(map, source, line, column, ALL_BOUND);
|
||||
allGeneratedPositionsFor = (map, { source, line, column, bias }) => {
|
||||
// SourceMapConsumer uses LEAST_UPPER_BOUND for some reason, so we follow suit.
|
||||
return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true);
|
||||
};
|
||||
generatedPositionFor = (map, { source, line, column, bias }) => {
|
||||
return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND);
|
||||
return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false);
|
||||
};
|
||||
eachMapping = (map, cb) => {
|
||||
const decoded = decodedMappings(map);
|
||||
@@ -466,7 +466,7 @@ class TraceMap {
|
||||
encodedMap = (map) => {
|
||||
return clone(map, encodedMappings(map));
|
||||
};
|
||||
function generatedPosition(map, source, line, column, bias) {
|
||||
function generatedPosition(map, source, line, column, bias, all) {
|
||||
line--;
|
||||
if (line < 0)
|
||||
throw new Error(LINE_GTR_ZERO);
|
||||
@@ -477,14 +477,14 @@ class TraceMap {
|
||||
if (sourceIndex === -1)
|
||||
sourceIndex = resolvedSources.indexOf(source);
|
||||
if (sourceIndex === -1)
|
||||
return bias === ALL_BOUND ? [] : GMapping(null, null);
|
||||
return all ? [] : GMapping(null, null);
|
||||
const generated = (map._bySources || (map._bySources = buildBySources(decodedMappings(map), (map._bySourceMemos = sources.map(memoizedState)))));
|
||||
const segments = generated[sourceIndex][line];
|
||||
if (segments == null)
|
||||
return bias === ALL_BOUND ? [] : GMapping(null, null);
|
||||
return all ? [] : GMapping(null, null);
|
||||
const memo = map._bySourceMemos[sourceIndex];
|
||||
if (bias === ALL_BOUND)
|
||||
return sliceGeneratedPositions(segments, memo, line, column);
|
||||
if (all)
|
||||
return sliceGeneratedPositions(segments, memo, line, column, bias);
|
||||
const index = traceSegmentInternal(segments, memo, line, column, bias);
|
||||
if (index === -1)
|
||||
return GMapping(null, null);
|
||||
@@ -520,9 +520,17 @@ function traceSegmentInternal(segments, memo, line, column, bias) {
|
||||
return -1;
|
||||
return index;
|
||||
}
|
||||
function sliceGeneratedPositions(segments, memo, line, column) {
|
||||
function sliceGeneratedPositions(segments, memo, line, column, bias) {
|
||||
let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND);
|
||||
if (min === -1)
|
||||
// We ignored the bias when tracing the segment so that we're guarnateed to find the first (in
|
||||
// insertion order) segment that matched. Even if we did respect the bias when tracing, we would
|
||||
// still need to call `lowerBound()` to find the first segment, which is slower than just looking
|
||||
// for the GREATEST_LOWER_BOUND to begin with. The only difference that matters for us is when the
|
||||
// binary search didn't match, in which case GREATEST_LOWER_BOUND just needs to increment to
|
||||
// match LEAST_UPPER_BOUND.
|
||||
if (!found && bias === LEAST_UPPER_BOUND)
|
||||
min++;
|
||||
if (min === -1 || min === segments.length)
|
||||
return [];
|
||||
// We may have found the segment that started at an earlier column. If this is the case, then we
|
||||
// need to slice all generated segments that match _that_ column, because all such segments span
|
||||
|
||||
Generated
Vendored
+19
-11
@@ -297,7 +297,6 @@
|
||||
const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';
|
||||
const LEAST_UPPER_BOUND = -1;
|
||||
const GREATEST_LOWER_BOUND = 1;
|
||||
const ALL_BOUND = 0;
|
||||
/**
|
||||
* Returns the encoded (VLQ string) form of the SourceMap's mappings field.
|
||||
*/
|
||||
@@ -416,11 +415,12 @@
|
||||
const { names, resolvedSources } = map;
|
||||
return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
|
||||
};
|
||||
exports.allGeneratedPositionsFor = (map, { source, line, column }) => {
|
||||
return generatedPosition(map, source, line, column, ALL_BOUND);
|
||||
exports.allGeneratedPositionsFor = (map, { source, line, column, bias }) => {
|
||||
// SourceMapConsumer uses LEAST_UPPER_BOUND for some reason, so we follow suit.
|
||||
return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true);
|
||||
};
|
||||
exports.generatedPositionFor = (map, { source, line, column, bias }) => {
|
||||
return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND);
|
||||
return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false);
|
||||
};
|
||||
exports.eachMapping = (map, cb) => {
|
||||
const decoded = exports.decodedMappings(map);
|
||||
@@ -473,7 +473,7 @@
|
||||
exports.encodedMap = (map) => {
|
||||
return clone(map, exports.encodedMappings(map));
|
||||
};
|
||||
function generatedPosition(map, source, line, column, bias) {
|
||||
function generatedPosition(map, source, line, column, bias, all) {
|
||||
line--;
|
||||
if (line < 0)
|
||||
throw new Error(LINE_GTR_ZERO);
|
||||
@@ -484,14 +484,14 @@
|
||||
if (sourceIndex === -1)
|
||||
sourceIndex = resolvedSources.indexOf(source);
|
||||
if (sourceIndex === -1)
|
||||
return bias === ALL_BOUND ? [] : GMapping(null, null);
|
||||
return all ? [] : GMapping(null, null);
|
||||
const generated = (map._bySources || (map._bySources = buildBySources(exports.decodedMappings(map), (map._bySourceMemos = sources.map(memoizedState)))));
|
||||
const segments = generated[sourceIndex][line];
|
||||
if (segments == null)
|
||||
return bias === ALL_BOUND ? [] : GMapping(null, null);
|
||||
return all ? [] : GMapping(null, null);
|
||||
const memo = map._bySourceMemos[sourceIndex];
|
||||
if (bias === ALL_BOUND)
|
||||
return sliceGeneratedPositions(segments, memo, line, column);
|
||||
if (all)
|
||||
return sliceGeneratedPositions(segments, memo, line, column, bias);
|
||||
const index = traceSegmentInternal(segments, memo, line, column, bias);
|
||||
if (index === -1)
|
||||
return GMapping(null, null);
|
||||
@@ -527,9 +527,17 @@
|
||||
return -1;
|
||||
return index;
|
||||
}
|
||||
function sliceGeneratedPositions(segments, memo, line, column) {
|
||||
function sliceGeneratedPositions(segments, memo, line, column, bias) {
|
||||
let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND);
|
||||
if (min === -1)
|
||||
// We ignored the bias when tracing the segment so that we're guarnateed to find the first (in
|
||||
// insertion order) segment that matched. Even if we did respect the bias when tracing, we would
|
||||
// still need to call `lowerBound()` to find the first segment, which is slower than just looking
|
||||
// for the GREATEST_LOWER_BOUND to begin with. The only difference that matters for us is when the
|
||||
// binary search didn't match, in which case GREATEST_LOWER_BOUND just needs to increment to
|
||||
// match LEAST_UPPER_BOUND.
|
||||
if (!found && bias === LEAST_UPPER_BOUND)
|
||||
min++;
|
||||
if (min === -1 || min === segments.length)
|
||||
return [];
|
||||
// We may have found the segment that started at an earlier column. If this is the case, then we
|
||||
// need to slice all generated segments that match _that_ column, because all such segments span
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@jridgewell/trace-mapping",
|
||||
"version": "0.3.16",
|
||||
"version": "0.3.17",
|
||||
"description": "Trace the original position through a source map",
|
||||
"keywords": [
|
||||
"source",
|
||||
|
||||
+1
-1
@@ -5527,7 +5527,7 @@
|
||||
|
||||
// Acorn is a tiny, fast JavaScript parser written in JavaScript.
|
||||
|
||||
var version = "8.8.0";
|
||||
var version = "8.8.1";
|
||||
|
||||
Parser.acorn = {
|
||||
Parser: Parser,
|
||||
|
||||
+1
-1
@@ -5521,7 +5521,7 @@ pp.readWord = function() {
|
||||
|
||||
// Acorn is a tiny, fast JavaScript parser written in JavaScript.
|
||||
|
||||
var version = "8.8.0";
|
||||
var version = "8.8.1";
|
||||
|
||||
Parser.acorn = {
|
||||
Parser: Parser,
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
],
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"version": "8.8.0",
|
||||
"version": "8.8.1",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
},
|
||||
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = (...arguments_) => {
|
||||
return [...new Set([].concat(...arguments_))];
|
||||
};
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
{
|
||||
"name": "array-union",
|
||||
"version": "2.1.0",
|
||||
"description": "Create an array of unique values, in order, from the input arrays",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/array-union",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"array",
|
||||
"set",
|
||||
"uniq",
|
||||
"unique",
|
||||
"duplicate",
|
||||
"remove",
|
||||
"union",
|
||||
"combine",
|
||||
"merge"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
# array-union [](https://travis-ci.org/sindresorhus/array-union)
|
||||
|
||||
> Create an array of unique values, in order, from the input arrays
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install array-union
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const arrayUnion = require('array-union');
|
||||
|
||||
arrayUnion([1, 1, 2, 3], [2, 3]);
|
||||
//=> [1, 2, 3]
|
||||
|
||||
arrayUnion(['foo', 'foo', 'bar']);
|
||||
//=> ['foo', 'bar']
|
||||
|
||||
arrayUnion(['🐱', '🦄', '🐻'], ['🦄', '🌈']);
|
||||
//=> ['🐱', '🦄', '🐻', '🌈']
|
||||
|
||||
arrayUnion(['🐱', '🦄'], ['🐻', '🦄'], ['🐶', '🌈', '🌈']);
|
||||
//=> ['🐱', '🦄', '🐻', '🐶', '🌈']
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2018, Jon Schlinkert.
|
||||
|
||||
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.
|
||||
-170
@@ -1,170 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const stringify = require('./lib/stringify');
|
||||
const compile = require('./lib/compile');
|
||||
const expand = require('./lib/expand');
|
||||
const parse = require('./lib/parse');
|
||||
|
||||
/**
|
||||
* Expand the given pattern or create a regex-compatible string.
|
||||
*
|
||||
* ```js
|
||||
* const braces = require('braces');
|
||||
* console.log(braces('{a,b,c}', { compile: true })); //=> ['(a|b|c)']
|
||||
* console.log(braces('{a,b,c}')); //=> ['a', 'b', 'c']
|
||||
* ```
|
||||
* @param {String} `str`
|
||||
* @param {Object} `options`
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
const braces = (input, options = {}) => {
|
||||
let output = [];
|
||||
|
||||
if (Array.isArray(input)) {
|
||||
for (let pattern of input) {
|
||||
let result = braces.create(pattern, options);
|
||||
if (Array.isArray(result)) {
|
||||
output.push(...result);
|
||||
} else {
|
||||
output.push(result);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
output = [].concat(braces.create(input, options));
|
||||
}
|
||||
|
||||
if (options && options.expand === true && options.nodupes === true) {
|
||||
output = [...new Set(output)];
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse the given `str` with the given `options`.
|
||||
*
|
||||
* ```js
|
||||
* // braces.parse(pattern, [, options]);
|
||||
* const ast = braces.parse('a/{b,c}/d');
|
||||
* console.log(ast);
|
||||
* ```
|
||||
* @param {String} pattern Brace pattern to parse
|
||||
* @param {Object} options
|
||||
* @return {Object} Returns an AST
|
||||
* @api public
|
||||
*/
|
||||
|
||||
braces.parse = (input, options = {}) => parse(input, options);
|
||||
|
||||
/**
|
||||
* Creates a braces string from an AST, or an AST node.
|
||||
*
|
||||
* ```js
|
||||
* const braces = require('braces');
|
||||
* let ast = braces.parse('foo/{a,b}/bar');
|
||||
* console.log(stringify(ast.nodes[2])); //=> '{a,b}'
|
||||
* ```
|
||||
* @param {String} `input` Brace pattern or AST.
|
||||
* @param {Object} `options`
|
||||
* @return {Array} Returns an array of expanded values.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
braces.stringify = (input, options = {}) => {
|
||||
if (typeof input === 'string') {
|
||||
return stringify(braces.parse(input, options), options);
|
||||
}
|
||||
return stringify(input, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Compiles a brace pattern into a regex-compatible, optimized string.
|
||||
* This method is called by the main [braces](#braces) function by default.
|
||||
*
|
||||
* ```js
|
||||
* const braces = require('braces');
|
||||
* console.log(braces.compile('a/{b,c}/d'));
|
||||
* //=> ['a/(b|c)/d']
|
||||
* ```
|
||||
* @param {String} `input` Brace pattern or AST.
|
||||
* @param {Object} `options`
|
||||
* @return {Array} Returns an array of expanded values.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
braces.compile = (input, options = {}) => {
|
||||
if (typeof input === 'string') {
|
||||
input = braces.parse(input, options);
|
||||
}
|
||||
return compile(input, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Expands a brace pattern into an array. This method is called by the
|
||||
* main [braces](#braces) function when `options.expand` is true. Before
|
||||
* using this method it's recommended that you read the [performance notes](#performance))
|
||||
* and advantages of using [.compile](#compile) instead.
|
||||
*
|
||||
* ```js
|
||||
* const braces = require('braces');
|
||||
* console.log(braces.expand('a/{b,c}/d'));
|
||||
* //=> ['a/b/d', 'a/c/d'];
|
||||
* ```
|
||||
* @param {String} `pattern` Brace pattern
|
||||
* @param {Object} `options`
|
||||
* @return {Array} Returns an array of expanded values.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
braces.expand = (input, options = {}) => {
|
||||
if (typeof input === 'string') {
|
||||
input = braces.parse(input, options);
|
||||
}
|
||||
|
||||
let result = expand(input, options);
|
||||
|
||||
// filter out empty strings if specified
|
||||
if (options.noempty === true) {
|
||||
result = result.filter(Boolean);
|
||||
}
|
||||
|
||||
// filter out duplicates if specified
|
||||
if (options.nodupes === true) {
|
||||
result = [...new Set(result)];
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Processes a brace pattern and returns either an expanded array
|
||||
* (if `options.expand` is true), a highly optimized regex-compatible string.
|
||||
* This method is called by the main [braces](#braces) function.
|
||||
*
|
||||
* ```js
|
||||
* const braces = require('braces');
|
||||
* console.log(braces.create('user-{200..300}/project-{a,b,c}-{1..10}'))
|
||||
* //=> 'user-(20[0-9]|2[1-9][0-9]|300)/project-(a|b|c)-([1-9]|10)'
|
||||
* ```
|
||||
* @param {String} `pattern` Brace pattern
|
||||
* @param {Object} `options`
|
||||
* @return {Array} Returns an array of expanded values.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
braces.create = (input, options = {}) => {
|
||||
if (input === '' || input.length < 3) {
|
||||
return [input];
|
||||
}
|
||||
|
||||
return options.expand !== true
|
||||
? braces.compile(input, options)
|
||||
: braces.expand(input, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose "braces"
|
||||
*/
|
||||
|
||||
module.exports = braces;
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const fill = require('fill-range');
|
||||
const utils = require('./utils');
|
||||
|
||||
const compile = (ast, options = {}) => {
|
||||
let walk = (node, parent = {}) => {
|
||||
let invalidBlock = utils.isInvalidBrace(parent);
|
||||
let invalidNode = node.invalid === true && options.escapeInvalid === true;
|
||||
let invalid = invalidBlock === true || invalidNode === true;
|
||||
let prefix = options.escapeInvalid === true ? '\\' : '';
|
||||
let output = '';
|
||||
|
||||
if (node.isOpen === true) {
|
||||
return prefix + node.value;
|
||||
}
|
||||
if (node.isClose === true) {
|
||||
return prefix + node.value;
|
||||
}
|
||||
|
||||
if (node.type === 'open') {
|
||||
return invalid ? (prefix + node.value) : '(';
|
||||
}
|
||||
|
||||
if (node.type === 'close') {
|
||||
return invalid ? (prefix + node.value) : ')';
|
||||
}
|
||||
|
||||
if (node.type === 'comma') {
|
||||
return node.prev.type === 'comma' ? '' : (invalid ? node.value : '|');
|
||||
}
|
||||
|
||||
if (node.value) {
|
||||
return node.value;
|
||||
}
|
||||
|
||||
if (node.nodes && node.ranges > 0) {
|
||||
let args = utils.reduce(node.nodes);
|
||||
let range = fill(...args, { ...options, wrap: false, toRegex: true });
|
||||
|
||||
if (range.length !== 0) {
|
||||
return args.length > 1 && range.length > 1 ? `(${range})` : range;
|
||||
}
|
||||
}
|
||||
|
||||
if (node.nodes) {
|
||||
for (let child of node.nodes) {
|
||||
output += walk(child, node);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
return walk(ast);
|
||||
};
|
||||
|
||||
module.exports = compile;
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
MAX_LENGTH: 1024 * 64,
|
||||
|
||||
// Digits
|
||||
CHAR_0: '0', /* 0 */
|
||||
CHAR_9: '9', /* 9 */
|
||||
|
||||
// Alphabet chars.
|
||||
CHAR_UPPERCASE_A: 'A', /* A */
|
||||
CHAR_LOWERCASE_A: 'a', /* a */
|
||||
CHAR_UPPERCASE_Z: 'Z', /* Z */
|
||||
CHAR_LOWERCASE_Z: 'z', /* z */
|
||||
|
||||
CHAR_LEFT_PARENTHESES: '(', /* ( */
|
||||
CHAR_RIGHT_PARENTHESES: ')', /* ) */
|
||||
|
||||
CHAR_ASTERISK: '*', /* * */
|
||||
|
||||
// Non-alphabetic chars.
|
||||
CHAR_AMPERSAND: '&', /* & */
|
||||
CHAR_AT: '@', /* @ */
|
||||
CHAR_BACKSLASH: '\\', /* \ */
|
||||
CHAR_BACKTICK: '`', /* ` */
|
||||
CHAR_CARRIAGE_RETURN: '\r', /* \r */
|
||||
CHAR_CIRCUMFLEX_ACCENT: '^', /* ^ */
|
||||
CHAR_COLON: ':', /* : */
|
||||
CHAR_COMMA: ',', /* , */
|
||||
CHAR_DOLLAR: '$', /* . */
|
||||
CHAR_DOT: '.', /* . */
|
||||
CHAR_DOUBLE_QUOTE: '"', /* " */
|
||||
CHAR_EQUAL: '=', /* = */
|
||||
CHAR_EXCLAMATION_MARK: '!', /* ! */
|
||||
CHAR_FORM_FEED: '\f', /* \f */
|
||||
CHAR_FORWARD_SLASH: '/', /* / */
|
||||
CHAR_HASH: '#', /* # */
|
||||
CHAR_HYPHEN_MINUS: '-', /* - */
|
||||
CHAR_LEFT_ANGLE_BRACKET: '<', /* < */
|
||||
CHAR_LEFT_CURLY_BRACE: '{', /* { */
|
||||
CHAR_LEFT_SQUARE_BRACKET: '[', /* [ */
|
||||
CHAR_LINE_FEED: '\n', /* \n */
|
||||
CHAR_NO_BREAK_SPACE: '\u00A0', /* \u00A0 */
|
||||
CHAR_PERCENT: '%', /* % */
|
||||
CHAR_PLUS: '+', /* + */
|
||||
CHAR_QUESTION_MARK: '?', /* ? */
|
||||
CHAR_RIGHT_ANGLE_BRACKET: '>', /* > */
|
||||
CHAR_RIGHT_CURLY_BRACE: '}', /* } */
|
||||
CHAR_RIGHT_SQUARE_BRACKET: ']', /* ] */
|
||||
CHAR_SEMICOLON: ';', /* ; */
|
||||
CHAR_SINGLE_QUOTE: '\'', /* ' */
|
||||
CHAR_SPACE: ' ', /* */
|
||||
CHAR_TAB: '\t', /* \t */
|
||||
CHAR_UNDERSCORE: '_', /* _ */
|
||||
CHAR_VERTICAL_LINE: '|', /* | */
|
||||
CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF' /* \uFEFF */
|
||||
};
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const fill = require('fill-range');
|
||||
const stringify = require('./stringify');
|
||||
const utils = require('./utils');
|
||||
|
||||
const append = (queue = '', stash = '', enclose = false) => {
|
||||
let result = [];
|
||||
|
||||
queue = [].concat(queue);
|
||||
stash = [].concat(stash);
|
||||
|
||||
if (!stash.length) return queue;
|
||||
if (!queue.length) {
|
||||
return enclose ? utils.flatten(stash).map(ele => `{${ele}}`) : stash;
|
||||
}
|
||||
|
||||
for (let item of queue) {
|
||||
if (Array.isArray(item)) {
|
||||
for (let value of item) {
|
||||
result.push(append(value, stash, enclose));
|
||||
}
|
||||
} else {
|
||||
for (let ele of stash) {
|
||||
if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
|
||||
result.push(Array.isArray(ele) ? append(item, ele, enclose) : (item + ele));
|
||||
}
|
||||
}
|
||||
}
|
||||
return utils.flatten(result);
|
||||
};
|
||||
|
||||
const expand = (ast, options = {}) => {
|
||||
let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
|
||||
|
||||
let walk = (node, parent = {}) => {
|
||||
node.queue = [];
|
||||
|
||||
let p = parent;
|
||||
let q = parent.queue;
|
||||
|
||||
while (p.type !== 'brace' && p.type !== 'root' && p.parent) {
|
||||
p = p.parent;
|
||||
q = p.queue;
|
||||
}
|
||||
|
||||
if (node.invalid || node.dollar) {
|
||||
q.push(append(q.pop(), stringify(node, options)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.type === 'brace' && node.invalid !== true && node.nodes.length === 2) {
|
||||
q.push(append(q.pop(), ['{}']));
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.nodes && node.ranges > 0) {
|
||||
let args = utils.reduce(node.nodes);
|
||||
|
||||
if (utils.exceedsLimit(...args, options.step, rangeLimit)) {
|
||||
throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
|
||||
}
|
||||
|
||||
let range = fill(...args, options);
|
||||
if (range.length === 0) {
|
||||
range = stringify(node, options);
|
||||
}
|
||||
|
||||
q.push(append(q.pop(), range));
|
||||
node.nodes = [];
|
||||
return;
|
||||
}
|
||||
|
||||
let enclose = utils.encloseBrace(node);
|
||||
let queue = node.queue;
|
||||
let block = node;
|
||||
|
||||
while (block.type !== 'brace' && block.type !== 'root' && block.parent) {
|
||||
block = block.parent;
|
||||
queue = block.queue;
|
||||
}
|
||||
|
||||
for (let i = 0; i < node.nodes.length; i++) {
|
||||
let child = node.nodes[i];
|
||||
|
||||
if (child.type === 'comma' && node.type === 'brace') {
|
||||
if (i === 1) queue.push('');
|
||||
queue.push('');
|
||||
continue;
|
||||
}
|
||||
|
||||
if (child.type === 'close') {
|
||||
q.push(append(q.pop(), queue, enclose));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (child.value && child.type !== 'open') {
|
||||
queue.push(append(queue.pop(), child.value));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (child.nodes) {
|
||||
walk(child, node);
|
||||
}
|
||||
}
|
||||
|
||||
return queue;
|
||||
};
|
||||
|
||||
return utils.flatten(walk(ast));
|
||||
};
|
||||
|
||||
module.exports = expand;
|
||||
-333
@@ -1,333 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const stringify = require('./stringify');
|
||||
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
|
||||
const {
|
||||
MAX_LENGTH,
|
||||
CHAR_BACKSLASH, /* \ */
|
||||
CHAR_BACKTICK, /* ` */
|
||||
CHAR_COMMA, /* , */
|
||||
CHAR_DOT, /* . */
|
||||
CHAR_LEFT_PARENTHESES, /* ( */
|
||||
CHAR_RIGHT_PARENTHESES, /* ) */
|
||||
CHAR_LEFT_CURLY_BRACE, /* { */
|
||||
CHAR_RIGHT_CURLY_BRACE, /* } */
|
||||
CHAR_LEFT_SQUARE_BRACKET, /* [ */
|
||||
CHAR_RIGHT_SQUARE_BRACKET, /* ] */
|
||||
CHAR_DOUBLE_QUOTE, /* " */
|
||||
CHAR_SINGLE_QUOTE, /* ' */
|
||||
CHAR_NO_BREAK_SPACE,
|
||||
CHAR_ZERO_WIDTH_NOBREAK_SPACE
|
||||
} = require('./constants');
|
||||
|
||||
/**
|
||||
* parse
|
||||
*/
|
||||
|
||||
const parse = (input, options = {}) => {
|
||||
if (typeof input !== 'string') {
|
||||
throw new TypeError('Expected a string');
|
||||
}
|
||||
|
||||
let opts = options || {};
|
||||
let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
||||
if (input.length > max) {
|
||||
throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
|
||||
}
|
||||
|
||||
let ast = { type: 'root', input, nodes: [] };
|
||||
let stack = [ast];
|
||||
let block = ast;
|
||||
let prev = ast;
|
||||
let brackets = 0;
|
||||
let length = input.length;
|
||||
let index = 0;
|
||||
let depth = 0;
|
||||
let value;
|
||||
let memo = {};
|
||||
|
||||
/**
|
||||
* Helpers
|
||||
*/
|
||||
|
||||
const advance = () => input[index++];
|
||||
const push = node => {
|
||||
if (node.type === 'text' && prev.type === 'dot') {
|
||||
prev.type = 'text';
|
||||
}
|
||||
|
||||
if (prev && prev.type === 'text' && node.type === 'text') {
|
||||
prev.value += node.value;
|
||||
return;
|
||||
}
|
||||
|
||||
block.nodes.push(node);
|
||||
node.parent = block;
|
||||
node.prev = prev;
|
||||
prev = node;
|
||||
return node;
|
||||
};
|
||||
|
||||
push({ type: 'bos' });
|
||||
|
||||
while (index < length) {
|
||||
block = stack[stack.length - 1];
|
||||
value = advance();
|
||||
|
||||
/**
|
||||
* Invalid chars
|
||||
*/
|
||||
|
||||
if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escaped chars
|
||||
*/
|
||||
|
||||
if (value === CHAR_BACKSLASH) {
|
||||
push({ type: 'text', value: (options.keepEscaping ? value : '') + advance() });
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Right square bracket (literal): ']'
|
||||
*/
|
||||
|
||||
if (value === CHAR_RIGHT_SQUARE_BRACKET) {
|
||||
push({ type: 'text', value: '\\' + value });
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Left square bracket: '['
|
||||
*/
|
||||
|
||||
if (value === CHAR_LEFT_SQUARE_BRACKET) {
|
||||
brackets++;
|
||||
|
||||
let closed = true;
|
||||
let next;
|
||||
|
||||
while (index < length && (next = advance())) {
|
||||
value += next;
|
||||
|
||||
if (next === CHAR_LEFT_SQUARE_BRACKET) {
|
||||
brackets++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (next === CHAR_BACKSLASH) {
|
||||
value += advance();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
||||
brackets--;
|
||||
|
||||
if (brackets === 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
push({ type: 'text', value });
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parentheses
|
||||
*/
|
||||
|
||||
if (value === CHAR_LEFT_PARENTHESES) {
|
||||
block = push({ type: 'paren', nodes: [] });
|
||||
stack.push(block);
|
||||
push({ type: 'text', value });
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value === CHAR_RIGHT_PARENTHESES) {
|
||||
if (block.type !== 'paren') {
|
||||
push({ type: 'text', value });
|
||||
continue;
|
||||
}
|
||||
block = stack.pop();
|
||||
push({ type: 'text', value });
|
||||
block = stack[stack.length - 1];
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quotes: '|"|`
|
||||
*/
|
||||
|
||||
if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
|
||||
let open = value;
|
||||
let next;
|
||||
|
||||
if (options.keepQuotes !== true) {
|
||||
value = '';
|
||||
}
|
||||
|
||||
while (index < length && (next = advance())) {
|
||||
if (next === CHAR_BACKSLASH) {
|
||||
value += next + advance();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (next === open) {
|
||||
if (options.keepQuotes === true) value += next;
|
||||
break;
|
||||
}
|
||||
|
||||
value += next;
|
||||
}
|
||||
|
||||
push({ type: 'text', value });
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Left curly brace: '{'
|
||||
*/
|
||||
|
||||
if (value === CHAR_LEFT_CURLY_BRACE) {
|
||||
depth++;
|
||||
|
||||
let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
|
||||
let brace = {
|
||||
type: 'brace',
|
||||
open: true,
|
||||
close: false,
|
||||
dollar,
|
||||
depth,
|
||||
commas: 0,
|
||||
ranges: 0,
|
||||
nodes: []
|
||||
};
|
||||
|
||||
block = push(brace);
|
||||
stack.push(block);
|
||||
push({ type: 'open', value });
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Right curly brace: '}'
|
||||
*/
|
||||
|
||||
if (value === CHAR_RIGHT_CURLY_BRACE) {
|
||||
if (block.type !== 'brace') {
|
||||
push({ type: 'text', value });
|
||||
continue;
|
||||
}
|
||||
|
||||
let type = 'close';
|
||||
block = stack.pop();
|
||||
block.close = true;
|
||||
|
||||
push({ type, value });
|
||||
depth--;
|
||||
|
||||
block = stack[stack.length - 1];
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comma: ','
|
||||
*/
|
||||
|
||||
if (value === CHAR_COMMA && depth > 0) {
|
||||
if (block.ranges > 0) {
|
||||
block.ranges = 0;
|
||||
let open = block.nodes.shift();
|
||||
block.nodes = [open, { type: 'text', value: stringify(block) }];
|
||||
}
|
||||
|
||||
push({ type: 'comma', value });
|
||||
block.commas++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dot: '.'
|
||||
*/
|
||||
|
||||
if (value === CHAR_DOT && depth > 0 && block.commas === 0) {
|
||||
let siblings = block.nodes;
|
||||
|
||||
if (depth === 0 || siblings.length === 0) {
|
||||
push({ type: 'text', value });
|
||||
continue;
|
||||
}
|
||||
|
||||
if (prev.type === 'dot') {
|
||||
block.range = [];
|
||||
prev.value += value;
|
||||
prev.type = 'range';
|
||||
|
||||
if (block.nodes.length !== 3 && block.nodes.length !== 5) {
|
||||
block.invalid = true;
|
||||
block.ranges = 0;
|
||||
prev.type = 'text';
|
||||
continue;
|
||||
}
|
||||
|
||||
block.ranges++;
|
||||
block.args = [];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (prev.type === 'range') {
|
||||
siblings.pop();
|
||||
|
||||
let before = siblings[siblings.length - 1];
|
||||
before.value += prev.value + value;
|
||||
prev = before;
|
||||
block.ranges--;
|
||||
continue;
|
||||
}
|
||||
|
||||
push({ type: 'dot', value });
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Text
|
||||
*/
|
||||
|
||||
push({ type: 'text', value });
|
||||
}
|
||||
|
||||
// Mark imbalanced braces and brackets as invalid
|
||||
do {
|
||||
block = stack.pop();
|
||||
|
||||
if (block.type !== 'root') {
|
||||
block.nodes.forEach(node => {
|
||||
if (!node.nodes) {
|
||||
if (node.type === 'open') node.isOpen = true;
|
||||
if (node.type === 'close') node.isClose = true;
|
||||
if (!node.nodes) node.type = 'text';
|
||||
node.invalid = true;
|
||||
}
|
||||
});
|
||||
|
||||
// get the location of the block on parent.nodes (block's siblings)
|
||||
let parent = stack[stack.length - 1];
|
||||
let index = parent.nodes.indexOf(block);
|
||||
// replace the (invalid) block with it's nodes
|
||||
parent.nodes.splice(index, 1, ...block.nodes);
|
||||
}
|
||||
} while (stack.length > 0);
|
||||
|
||||
push({ type: 'eos' });
|
||||
return ast;
|
||||
};
|
||||
|
||||
module.exports = parse;
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = (ast, options = {}) => {
|
||||
let stringify = (node, parent = {}) => {
|
||||
let invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
|
||||
let invalidNode = node.invalid === true && options.escapeInvalid === true;
|
||||
let output = '';
|
||||
|
||||
if (node.value) {
|
||||
if ((invalidBlock || invalidNode) && utils.isOpenOrClose(node)) {
|
||||
return '\\' + node.value;
|
||||
}
|
||||
return node.value;
|
||||
}
|
||||
|
||||
if (node.value) {
|
||||
return node.value;
|
||||
}
|
||||
|
||||
if (node.nodes) {
|
||||
for (let child of node.nodes) {
|
||||
output += stringify(child);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
return stringify(ast);
|
||||
};
|
||||
|
||||
-112
@@ -1,112 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
exports.isInteger = num => {
|
||||
if (typeof num === 'number') {
|
||||
return Number.isInteger(num);
|
||||
}
|
||||
if (typeof num === 'string' && num.trim() !== '') {
|
||||
return Number.isInteger(Number(num));
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Find a node of the given type
|
||||
*/
|
||||
|
||||
exports.find = (node, type) => node.nodes.find(node => node.type === type);
|
||||
|
||||
/**
|
||||
* Find a node of the given type
|
||||
*/
|
||||
|
||||
exports.exceedsLimit = (min, max, step = 1, limit) => {
|
||||
if (limit === false) return false;
|
||||
if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
|
||||
return ((Number(max) - Number(min)) / Number(step)) >= limit;
|
||||
};
|
||||
|
||||
/**
|
||||
* Escape the given node with '\\' before node.value
|
||||
*/
|
||||
|
||||
exports.escapeNode = (block, n = 0, type) => {
|
||||
let node = block.nodes[n];
|
||||
if (!node) return;
|
||||
|
||||
if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
|
||||
if (node.escaped !== true) {
|
||||
node.value = '\\' + node.value;
|
||||
node.escaped = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the given brace node should be enclosed in literal braces
|
||||
*/
|
||||
|
||||
exports.encloseBrace = node => {
|
||||
if (node.type !== 'brace') return false;
|
||||
if ((node.commas >> 0 + node.ranges >> 0) === 0) {
|
||||
node.invalid = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if a brace node is invalid.
|
||||
*/
|
||||
|
||||
exports.isInvalidBrace = block => {
|
||||
if (block.type !== 'brace') return false;
|
||||
if (block.invalid === true || block.dollar) return true;
|
||||
if ((block.commas >> 0 + block.ranges >> 0) === 0) {
|
||||
block.invalid = true;
|
||||
return true;
|
||||
}
|
||||
if (block.open !== true || block.close !== true) {
|
||||
block.invalid = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if a node is an open or close node
|
||||
*/
|
||||
|
||||
exports.isOpenOrClose = node => {
|
||||
if (node.type === 'open' || node.type === 'close') {
|
||||
return true;
|
||||
}
|
||||
return node.open === true || node.close === true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reduce an array of text nodes.
|
||||
*/
|
||||
|
||||
exports.reduce = nodes => nodes.reduce((acc, node) => {
|
||||
if (node.type === 'text') acc.push(node.value);
|
||||
if (node.type === 'range') node.type = 'text';
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Flatten an array
|
||||
*/
|
||||
|
||||
exports.flatten = (...args) => {
|
||||
const result = [];
|
||||
const flat = arr => {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
let ele = arr[i];
|
||||
Array.isArray(ele) ? flat(ele, result) : ele !== void 0 && result.push(ele);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
flat(args);
|
||||
return result;
|
||||
};
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
{
|
||||
"name": "braces",
|
||||
"description": "Bash-like brace expansion, implemented in JavaScript. Safer than other brace expansion libs, with complete support for the Bash 4.3 braces specification, without sacrificing speed.",
|
||||
"version": "3.0.2",
|
||||
"homepage": "https://github.com/micromatch/braces",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"contributors": [
|
||||
"Brian Woodward (https://twitter.com/doowb)",
|
||||
"Elan Shanker (https://github.com/es128)",
|
||||
"Eugene Sharygin (https://github.com/eush77)",
|
||||
"hemanth.hm (http://h3manth.com)",
|
||||
"Jon Schlinkert (http://twitter.com/jonschlinkert)"
|
||||
],
|
||||
"repository": "micromatch/braces",
|
||||
"bugs": {
|
||||
"url": "https://github.com/micromatch/braces/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"benchmark": "node benchmark"
|
||||
},
|
||||
"dependencies": {
|
||||
"fill-range": "^7.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ansi-colors": "^3.2.4",
|
||||
"bash-path": "^2.0.1",
|
||||
"gulp-format-md": "^2.0.0",
|
||||
"mocha": "^6.1.1"
|
||||
},
|
||||
"keywords": [
|
||||
"alpha",
|
||||
"alphabetical",
|
||||
"bash",
|
||||
"brace",
|
||||
"braces",
|
||||
"expand",
|
||||
"expansion",
|
||||
"filepath",
|
||||
"fill",
|
||||
"fs",
|
||||
"glob",
|
||||
"globbing",
|
||||
"letter",
|
||||
"match",
|
||||
"matches",
|
||||
"matching",
|
||||
"number",
|
||||
"numerical",
|
||||
"path",
|
||||
"range",
|
||||
"ranges",
|
||||
"sh"
|
||||
],
|
||||
"verb": {
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
},
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
]
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1 +1 @@
|
||||
module.exports={A:{A:{J:0.0131217,D:0.00621152,E:0.0360158,F:0.086438,A:0.00720317,B:0.475409,"4B":0.009298},B:"ms",C:["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","4B","J","D","E","F","A","B","","",""],E:"IE",F:{"4B":962323200,J:998870400,D:1161129600,E:1237420800,F:1300060800,A:1346716800,B:1381968000}},B:{A:{C:0.007858,K:0.004267,L:0.004268,G:0.003929,M:0.003702,N:0.007858,O:0.023574,P:0,Q:0.004298,R:0.00944,S:0.004043,T:0.007858,U:0.007858,V:0.003929,W:0.003929,X:0.004318,Y:0.003929,Z:0.004118,a:0.003939,d:0.007858,e:0.004118,f:0.003939,g:0.003801,h:0.003929,i:0.003855,j:0.003929,k:0.003929,l:0.007858,m:0.019645,n:0.015716,o:0.055006,p:0.652214,b:3.4143,H:0},B:"webkit",C:["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","C","K","L","G","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","d","e","f","g","h","i","j","k","l","m","n","o","p","b","H","","",""],E:"Edge",F:{C:1438128000,K:1447286400,L:1470096000,G:1491868800,M:1508198400,N:1525046400,O:1542067200,P:1579046400,Q:1581033600,R:1586736000,S:1590019200,T:1594857600,U:1598486400,V:1602201600,W:1605830400,X:1611360000,Y:1614816000,Z:1618358400,a:1622073600,d:1626912000,e:1630627200,f:1632441600,g:1634774400,h:1637539200,i:1641427200,j:1643932800,k:1646265600,l:1649635200,m:1651190400,n:1653955200,o:1655942400,p:1659657600,b:1661990400,H:1664755200},D:{C:"ms",K:"ms",L:"ms",G:"ms",M:"ms",N:"ms",O:"ms"}},C:{A:{"0":0.004418,"1":0.008834,"2":0.008322,"3":0.008928,"4":0.004471,"5":0.009284,"6":0.004707,"7":0.009076,"8":0.007858,"9":0.004783,"5B":0.004118,pB:0.004271,I:0.019645,q:0.004879,J:0.020136,D:0.005725,E:0.004525,F:0.00533,A:0.004283,B:0.007858,C:0.004471,K:0.004486,L:0.00453,G:0.008322,M:0.004417,N:0.004425,O:0.004161,r:0.004443,s:0.004283,t:0.008322,u:0.013698,v:0.004161,w:0.008786,x:0.004118,y:0.004317,z:0.004393,AB:0.003929,BB:0.004783,CB:0.00487,DB:0.005029,EB:0.0047,FB:0.011787,GB:0.007858,HB:0.003867,IB:0.004525,JB:0.004293,KB:0.003702,LB:0.004538,MB:0.008282,NB:0.011601,OB:0.055006,PB:0.011601,QB:0.003929,RB:0.007858,SB:0.003929,TB:0.011601,UB:0.003939,qB:0.003855,VB:0.003929,rB:0.004356,WB:0.004425,XB:0.008322,c:0.00415,YB:0.004267,ZB:0.003801,aB:0.004267,bB:0.007858,cB:0.00415,dB:0.004293,eB:0.004425,fB:0.003929,gB:0.00415,hB:0.00415,iB:0.004318,jB:0.004356,kB:0.003929,lB:0.03929,P:0.007858,Q:0.007858,R:0.007858,sB:0.007858,S:0.007858,T:0.003929,U:0.004268,V:0.003801,W:0.011787,X:0.007858,Y:0.003929,Z:0.003929,a:0.070722,d:0.003801,e:0.003855,f:0.019645,g:0.007858,h:0.003929,i:0.007858,j:0.007858,k:0.011787,l:0.011787,m:0.011787,n:0.051077,o:0.141444,p:1.60303,b:0.542202,H:0.007858,tB:0,"6B":0.008786,"7B":0.00487},B:"moz",C:["5B","pB","6B","7B","I","q","J","D","E","F","A","B","C","K","L","G","M","N","O","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","AB","BB","CB","DB","EB","FB","GB","HB","IB","JB","KB","LB","MB","NB","OB","PB","QB","RB","SB","TB","UB","qB","VB","rB","WB","XB","c","YB","ZB","aB","bB","cB","dB","eB","fB","gB","hB","iB","jB","kB","lB","P","Q","R","sB","S","T","U","V","W","X","Y","Z","a","d","e","f","g","h","i","j","k","l","m","n","o","p","b","H","tB",""],E:"Firefox",F:{"0":1395100800,"1":1398729600,"2":1402358400,"3":1405987200,"4":1409616000,"5":1413244800,"6":1417392000,"7":1421107200,"8":1424736000,"9":1428278400,"5B":1161648000,pB:1213660800,"6B":1246320000,"7B":1264032000,I:1300752000,q:1308614400,J:1313452800,D:1317081600,E:1317081600,F:1320710400,A:1324339200,B:1327968000,C:1331596800,K:1335225600,L:1338854400,G:1342483200,M:1346112000,N:1349740800,O:1353628800,r:1357603200,s:1361232000,t:1364860800,u:1368489600,v:1372118400,w:1375747200,x:1379376000,y:1386633600,z:1391472000,AB:1431475200,BB:1435881600,CB:1439251200,DB:1442880000,EB:1446508800,FB:1450137600,GB:1453852800,HB:1457395200,IB:1461628800,JB:1465257600,KB:1470096000,LB:1474329600,MB:1479168000,NB:1485216000,OB:1488844800,PB:1492560000,QB:1497312000,RB:1502150400,SB:1506556800,TB:1510617600,UB:1516665600,qB:1520985600,VB:1525824000,rB:1529971200,WB:1536105600,XB:1540252800,c:1544486400,YB:1548720000,ZB:1552953600,aB:1558396800,bB:1562630400,cB:1567468800,dB:1571788800,eB:1575331200,fB:1578355200,gB:1581379200,hB:1583798400,iB:1586304000,jB:1588636800,kB:1591056000,lB:1593475200,P:1595894400,Q:1598313600,R:1600732800,sB:1603152000,S:1605571200,T:1607990400,U:1611619200,V:1614038400,W:1616457600,X:1618790400,Y:1622505600,Z:1626134400,a:1628553600,d:1630972800,e:1633392000,f:1635811200,g:1638835200,h:1641859200,i:1644364800,j:1646697600,k:1649116800,l:1651536000,m:1653955200,n:1656374400,o:1658793600,p:1661212800Line truncated
|
||||
module.exports={A:{A:{J:0.0131217,E:0.00621152,F:0.0360158,G:0.086438,A:0.00720317,B:0.475409,"5B":0.009298},B:"ms",C:["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","5B","J","E","F","G","A","B","","",""],E:"IE",F:{"5B":962323200,J:998870400,E:1161129600,F:1237420800,G:1300060800,A:1346716800,B:1381968000}},B:{A:{C:0.007858,K:0.004267,L:0.004268,H:0.003929,M:0.003702,N:0.007858,O:0.023574,P:0,Q:0.004298,R:0.00944,S:0.004043,T:0.007858,U:0.007858,V:0.003929,W:0.003929,X:0.004318,Y:0.003929,Z:0.004118,a:0.003939,c:0.007858,d:0.004118,e:0.003939,f:0.003801,g:0.003929,h:0.003855,i:0.003929,j:0.003929,k:0.007858,l:0.019645,m:0.015716,n:0.055006,o:0.652214,p:3.4143,D:0},B:"webkit",C:["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","C","K","L","H","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","c","d","e","f","g","h","i","j","k","l","m","n","o","p","D","","",""],E:"Edge",F:{C:1438128000,K:1447286400,L:1470096000,H:1491868800,M:1508198400,N:1525046400,O:1542067200,P:1579046400,Q:1581033600,R:1586736000,S:1590019200,T:1594857600,U:1598486400,V:1602201600,W:1605830400,X:1611360000,Y:1614816000,Z:1618358400,a:1622073600,c:1626912000,d:1630627200,e:1632441600,f:1634774400,g:1637539200,h:1641427200,i:1643932800,j:1646265600,k:1649635200,l:1651190400,m:1653955200,n:1655942400,o:1659657600,p:1661990400,D:1664755200},D:{C:"ms",K:"ms",L:"ms",H:"ms",M:"ms",N:"ms",O:"ms"}},C:{A:{"0":0.004418,"1":0.008834,"2":0.008322,"3":0.008928,"4":0.004471,"5":0.009284,"6":0.004707,"7":0.009076,"8":0.007858,"9":0.004783,"6B":0.004118,pB:0.004271,I:0.019645,q:0.004879,J:0.020136,E:0.005725,F:0.004525,G:0.00533,A:0.004283,B:0.007858,C:0.004471,K:0.004486,L:0.00453,H:0.008322,M:0.004417,N:0.004425,O:0.004161,r:0.004443,s:0.004283,t:0.008322,u:0.013698,v:0.004161,w:0.008786,x:0.004118,y:0.004317,z:0.004393,AB:0.003929,BB:0.004783,CB:0.00487,DB:0.005029,EB:0.0047,FB:0.011787,GB:0.007858,HB:0.003867,IB:0.004525,JB:0.004293,KB:0.003702,LB:0.004538,MB:0.008282,NB:0.011601,OB:0.055006,PB:0.011601,QB:0.003929,RB:0.007858,SB:0.003929,TB:0.011601,UB:0.003939,qB:0.003855,VB:0.003929,rB:0.004356,WB:0.004425,XB:0.008322,b:0.00415,YB:0.004267,ZB:0.003801,aB:0.004267,bB:0.007858,cB:0.00415,dB:0.004293,eB:0.004425,fB:0.003929,gB:0.00415,hB:0.00415,iB:0.004318,jB:0.004356,kB:0.003929,lB:0.03929,P:0.007858,Q:0.007858,R:0.007858,sB:0.007858,S:0.007858,T:0.003929,U:0.004268,V:0.003801,W:0.011787,X:0.007858,Y:0.003929,Z:0.003929,a:0.070722,c:0.003801,d:0.003855,e:0.019645,f:0.007858,g:0.003929,h:0.007858,i:0.007858,j:0.011787,k:0.011787,l:0.011787,m:0.051077,n:0.141444,o:1.60303,p:0.542202,D:0.007858,tB:0,uB:0,"7B":0.008786,"8B":0.00487},B:"moz",C:["6B","pB","7B","8B","I","q","J","E","F","G","A","B","C","K","L","H","M","N","O","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","AB","BB","CB","DB","EB","FB","GB","HB","IB","JB","KB","LB","MB","NB","OB","PB","QB","RB","SB","TB","UB","qB","VB","rB","WB","XB","b","YB","ZB","aB","bB","cB","dB","eB","fB","gB","hB","iB","jB","kB","lB","P","Q","R","sB","S","T","U","V","W","X","Y","Z","a","c","d","e","f","g","h","i","j","k","l","m","n","o","p","D","tB","uB",""],E:"Firefox",F:{"0":1395100800,"1":1398729600,"2":1402358400,"3":1405987200,"4":1409616000,"5":1413244800,"6":1417392000,"7":1421107200,"8":1424736000,"9":1428278400,"6B":1161648000,pB:1213660800,"7B":1246320000,"8B":1264032000,I:1300752000,q:1308614400,J:1313452800,E:1317081600,F:1317081600,G:1320710400,A:1324339200,B:1327968000,C:1331596800,K:1335225600,L:1338854400,H:1342483200,M:1346112000,N:1349740800,O:1353628800,r:1357603200,s:1361232000,t:1364860800,u:1368489600,v:1372118400,w:1375747200,x:1379376000,y:1386633600,z:1391472000,AB:1431475200,BB:1435881600,CB:1439251200,DB:1442880000,EB:1446508800,FB:1450137600,GB:1453852800,HB:1457395200,IB:1461628800,JB:1465257600,KB:1470096000,LB:1474329600,MB:1479168000,NB:1485216000,OB:1488844800,PB:1492560000,QB:1497312000,RB:1502150400,SB:1506556800,TB:1510617600,UB:1516665600,qB:1520985600,VB:1525824000,rB:1529971200,WB:1536105600,XB:1540252800,b:1544486400,YB:1548720000,ZB:1552953600,aB:1558396800,bB:1562630400,cB:1567468800,dB:1571788800,eB:1575331200,fB:1578355200,gB:1581379200,hB:1583798400,iB:1586304000,jB:1588636800,kB:1591056000,lB:1593475200,P:1595894400,Q:1598313600,R:1600732800,sB:1603152000,S:1605571200,T:1607990400,U:1611619200,V:1614038400,W:1616457600,X:1618790400,Y:1622505600,Z:1626134400,a:1628553600,c:1630972800,d:1633392000,e:1635811200,f:1638835200,g:1641859200,h:1644364800,i:1646697600,j:1649116800,k:1651536000,l:1653955200,m:1656374400,n:1658793Line truncated
|
||||
Loaded 100 of 805 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user