mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
tools: update eslint to 8.27.0
PR-URL: https://github.com/nodejs/node/pull/45358 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
committed by
GitHub
parent
7c6682957b
commit
c5824b87a4
137
tools/node_modules/eslint/lib/cli-engine/formatters/html.js
generated
vendored
137
tools/node_modules/eslint/lib/cli-engine/formatters/html.js
generated
vendored
@@ -43,85 +43,110 @@ function pageTemplate(it) {
|
||||
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PScwIDAgMjk0LjgyNSAyNTguOTgyJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnPg0KPHBhdGggZmlsbD0nIzgwODBGMicgZD0nTTk3LjAyMSw5OS4wMTZsNDguNDMyLTI3Ljk2MmMxLjIxMi0wLjcsMi43MDYtMC43LDMuOTE4LDBsNDguNDMzLDI3Ljk2MiBjMS4yMTEsMC43LDEuOTU5LDEuOTkzLDEuOTU5LDMuMzkzdjU1LjkyNGMwLDEuMzk5LTAuNzQ4LDIuNjkzLTEuOTU5LDMuMzk0bC00OC40MzMsMjcuOTYyYy0xLjIxMiwwLjctMi43MDYsMC43LTMuOTE4LDAgbC00OC40MzItMjcuOTYyYy0xLjIxMi0wLjctMS45NTktMS45OTQtMS45NTktMy4zOTR2LTU1LjkyNEM5NS4wNjMsMTAxLjAwOSw5NS44MSw5OS43MTYsOTcuMDIxLDk5LjAxNicvPg0KPHBhdGggZmlsbD0nIzRCMzJDMycgZD0nTTI3My4zMzYsMTI0LjQ4OEwyMTUuNDY5LDIzLjgxNmMtMi4xMDItMy42NC01Ljk4NS02LjMyNS0xMC4xODgtNi4zMjVIODkuNTQ1IGMtNC4yMDQsMC04LjA4OCwyLjY4NS0xMC4xOSw2LjMyNWwtNTcuODY3LDEwMC40NWMtMi4xMDIsMy42NDEtMi4xMDIsOC4yMzYsMCwxMS44NzdsNTcuODY3LDk5Ljg0NyBjMi4xMDIsMy42NCw1Ljk4Niw1LjUwMSwxMC4xOSw1LjUwMWgxMTUuNzM1YzQuMjAzLDAsOC4wODctMS44MDUsMTAuMTg4LTUuNDQ2bDU3Ljg2Ny0xMDAuMDEgQzI3NS40MzksMTMyLjM5NiwyNzUuNDM5LDEyOC4xMjgsMjczLjMzNiwxMjQuNDg4IE0yMjUuNDE5LDE3Mi44OThjMCwxLjQ4LTAuODkxLDIuODQ5LTIuMTc0LDMuNTlsLTczLjcxLDQyLjUyNyBjLTEuMjgyLDAuNzQtMi44ODgsMC43NC00LjE3LDBsLTczLjc2Ny00Mi41MjdjLTEuMjgyLTAuNzQxLTIuMTc5LTIuMTA5LTIuMTc5LTMuNTlWODcuODQzYzAtMS40ODEsMC44ODQtMi44NDksMi4xNjctMy41OSBsNzMuNzA3LTQyLjUyN2MxLjI4Mi0wLjc0MSwyLjg4Ni0wLjc0MSw0LjE2OCwwbDczLjc3Miw0Mi41MjdjMS4yODMsMC43NDEsMi4xODYsMi4xMDksMi4xODYsMy41OVYxNzIuODk4eicvPg0KPC9zdmc+">
|
||||
<style>
|
||||
body {
|
||||
font-family:Arial, "Helvetica Neue", Helvetica, sans-serif;
|
||||
font-size:16px;
|
||||
font-weight:normal;
|
||||
margin:0;
|
||||
padding:0;
|
||||
color:#333
|
||||
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
|
||||
font-size: 16px;
|
||||
font-weight: normal;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
#overview {
|
||||
padding:20px 30px
|
||||
}
|
||||
td, th {
|
||||
padding:5px 10px
|
||||
}
|
||||
h1 {
|
||||
margin:0
|
||||
}
|
||||
table {
|
||||
margin:30px;
|
||||
width:calc(100% - 60px);
|
||||
max-width:1000px;
|
||||
border-radius:5px;
|
||||
border:1px solid #ddd;
|
||||
border-spacing:0px;
|
||||
padding: 20px 30px;
|
||||
}
|
||||
|
||||
td,
|
||||
th {
|
||||
font-weight:400;
|
||||
font-size:medium;
|
||||
text-align:left;
|
||||
cursor:pointer
|
||||
padding: 5px 10px;
|
||||
}
|
||||
td.clr-1, td.clr-2, th span {
|
||||
font-weight:700
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
table {
|
||||
margin: 30px;
|
||||
width: calc(100% - 60px);
|
||||
max-width: 1000px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #ddd;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
th {
|
||||
font-weight: 400;
|
||||
font-size: medium;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
td.clr-1,
|
||||
td.clr-2,
|
||||
th span {
|
||||
float:right;
|
||||
margin-left:20px
|
||||
font-weight: 700;
|
||||
}
|
||||
th span:after {
|
||||
content:"";
|
||||
clear:both;
|
||||
display:block
|
||||
|
||||
th span {
|
||||
float: right;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
th span::after {
|
||||
content: "";
|
||||
clear: both;
|
||||
display: block;
|
||||
}
|
||||
|
||||
tr:last-child td {
|
||||
border-bottom:none
|
||||
border-bottom: none;
|
||||
}
|
||||
tr td:first-child, tr td:last-child {
|
||||
color:#9da0a4
|
||||
|
||||
tr td:first-child,
|
||||
tr td:last-child {
|
||||
color: #9da0a4;
|
||||
}
|
||||
#overview.bg-0, tr.bg-0 th {
|
||||
color:#468847;
|
||||
background:#dff0d8;
|
||||
border-bottom:1px solid #d6e9c6
|
||||
|
||||
#overview.bg-0,
|
||||
tr.bg-0 th {
|
||||
color: #468847;
|
||||
background: #dff0d8;
|
||||
border-bottom: 1px solid #d6e9c6;
|
||||
}
|
||||
#overview.bg-1, tr.bg-1 th {
|
||||
color:#f0ad4e;
|
||||
background:#fcf8e3;
|
||||
border-bottom:1px solid #fbeed5
|
||||
|
||||
#overview.bg-1,
|
||||
tr.bg-1 th {
|
||||
color: #f0ad4e;
|
||||
background: #fcf8e3;
|
||||
border-bottom: 1px solid #fbeed5;
|
||||
}
|
||||
#overview.bg-2, tr.bg-2 th {
|
||||
color:#b94a48;
|
||||
background:#f2dede;
|
||||
border-bottom:1px solid #eed3d7
|
||||
|
||||
#overview.bg-2,
|
||||
tr.bg-2 th {
|
||||
color: #b94a48;
|
||||
background: #f2dede;
|
||||
border-bottom: 1px solid #eed3d7;
|
||||
}
|
||||
|
||||
td {
|
||||
border-bottom:1px solid #ddd
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
td.clr-1 {
|
||||
color:#f0ad4e
|
||||
color: #f0ad4e;
|
||||
}
|
||||
|
||||
td.clr-2 {
|
||||
color:#b94a48
|
||||
color: #b94a48;
|
||||
}
|
||||
|
||||
td a {
|
||||
color:#3a33d1;
|
||||
text-decoration:none
|
||||
color: #3a33d1;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
td a:hover {
|
||||
color:#272296;
|
||||
text-decoration:underline
|
||||
color: #272296;
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
@@ -214,7 +239,7 @@ function messageTemplate(it) {
|
||||
} = it;
|
||||
|
||||
return `
|
||||
<tr style="display:none" class="f-${parentIndex}">
|
||||
<tr style="display: none;" class="f-${parentIndex}">
|
||||
<td>${lineNumber}:${columnNumber}</td>
|
||||
<td class="clr-${severityNumber}">${severityName}</td>
|
||||
<td>${encodeHTML(message)}</td>
|
||||
|
||||
394
tools/node_modules/eslint/lib/eslint/eslint-helpers.js
generated
vendored
394
tools/node_modules/eslint/lib/eslint/eslint-helpers.js
generated
vendored
@@ -27,6 +27,17 @@ const isPathInside = require("is-path-inside");
|
||||
const doFsWalk = util.promisify(fswalk.walk);
|
||||
const Minimatch = minimatch.Minimatch;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Types
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @typedef {Object} GlobSearch
|
||||
* @property {Array<string>} patterns The normalized patterns to use for a search.
|
||||
* @property {Array<string>} rawPatterns The patterns as entered by the user
|
||||
* before doing any normalization.
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Errors
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -47,6 +58,30 @@ class NoFilesFoundError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The error type when a search fails to match multiple patterns.
|
||||
*/
|
||||
class UnmatchedSearchPatternsError extends Error {
|
||||
|
||||
/**
|
||||
* @param {Object} options The options for the error.
|
||||
* @param {string} options.basePath The directory that was searched.
|
||||
* @param {Array<string>} options.unmatchedPatterns The glob patterns
|
||||
* which were not found.
|
||||
* @param {Array<string>} options.patterns The glob patterns that were
|
||||
* searched.
|
||||
* @param {Array<string>} options.rawPatterns The raw glob patterns that
|
||||
* were searched.
|
||||
*/
|
||||
constructor({ basePath, unmatchedPatterns, patterns, rawPatterns }) {
|
||||
super(`No files matching '${rawPatterns}' in '${basePath}' were found.`);
|
||||
this.basePath = basePath;
|
||||
this.patternsToCheck = unmatchedPatterns;
|
||||
this.patterns = patterns;
|
||||
this.rawPatterns = rawPatterns;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The error type when there are files matched by a glob, but all of them have been ignored.
|
||||
*/
|
||||
@@ -107,6 +142,323 @@ function isGlobPattern(pattern) {
|
||||
return isGlob(path.sep === "\\" ? normalizeToPosix(pattern) : pattern);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {Array<string>} options.rawPatterns An array of glob patterns
|
||||
* as the user inputted them. Used for errors.
|
||||
* @param {FlatConfigArray} options.configs The config array to use for
|
||||
* determining what to ignore.
|
||||
* @param {boolean} options.errorOnUnmatchedPattern Determines if an error
|
||||
* should be thrown when a pattern is unmatched.
|
||||
* @returns {Promise<Array<string>>} An array of matching file paths
|
||||
* or an empty array if there are no matches.
|
||||
* @throws {UnmatchedSearchPatternsErrror} If there is a pattern that doesn't
|
||||
* match any files.
|
||||
*/
|
||||
async function globSearch({
|
||||
basePath,
|
||||
patterns,
|
||||
rawPatterns,
|
||||
configs,
|
||||
errorOnUnmatchedPattern
|
||||
}) {
|
||||
|
||||
if (patterns.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/*
|
||||
* In this section we are converting the patterns into Minimatch
|
||||
* instances for performance reasons. Because we are doing the same
|
||||
* matches repeatedly, it's best to compile those patterns once and
|
||||
* reuse them multiple times.
|
||||
*
|
||||
* To do that, we convert any patterns with an absolute path into a
|
||||
* relative path and normalize it to Posix-style slashes. We also keep
|
||||
* track of the relative patterns to map them back to the original
|
||||
* patterns, which we need in order to throw an error if there are any
|
||||
* unmatched patterns.
|
||||
*/
|
||||
const relativeToPatterns = new Map();
|
||||
const matchers = patterns.map((pattern, i) => {
|
||||
const patternToUse = path.isAbsolute(pattern)
|
||||
? normalizeToPosix(path.relative(basePath, pattern))
|
||||
: pattern;
|
||||
|
||||
relativeToPatterns.set(patternToUse, patterns[i]);
|
||||
|
||||
return new minimatch.Minimatch(patternToUse);
|
||||
});
|
||||
|
||||
/*
|
||||
* We track unmatched patterns because we may want to throw an error when
|
||||
* they occur. To start, this set is initialized with all of the patterns.
|
||||
* Every time a match occurs, the pattern is removed from the set, making
|
||||
* it easy to tell if we have any unmatched patterns left at the end of
|
||||
* search.
|
||||
*/
|
||||
const unmatchedPatterns = new Set([...relativeToPatterns.keys()]);
|
||||
|
||||
const filePaths = (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;
|
||||
}
|
||||
|
||||
/*
|
||||
* Optimization: We need to track when patterns are left unmatched
|
||||
* and so we use `unmatchedPatterns` to do that. There is a bit of
|
||||
* complexity here because the same file can be matched by more than
|
||||
* one pattern. So, when we start, we actually need to test every
|
||||
* pattern against every file. Once we know there are no remaining
|
||||
* unmatched patterns, then we can switch to just looking for the
|
||||
* first matching pattern for improved speed.
|
||||
*/
|
||||
const matchesPattern = unmatchedPatterns.size > 0
|
||||
? matchers.reduce((previousValue, matcher) => {
|
||||
const pathMatches = matcher.match(relativePath);
|
||||
|
||||
/*
|
||||
* We updated the unmatched patterns set only if the path
|
||||
* matches and the file isn't ignored. If the file is
|
||||
* ignored, that means there wasn't a match for the
|
||||
* pattern so it should not be removed.
|
||||
*
|
||||
* Performance note: isFileIgnored() aggressively caches
|
||||
* results so there is no performance penalty for calling
|
||||
* it twice with the same argument.
|
||||
*/
|
||||
if (pathMatches && !configs.isFileIgnored(entry.path)) {
|
||||
unmatchedPatterns.delete(matcher.pattern);
|
||||
}
|
||||
|
||||
return pathMatches || previousValue;
|
||||
}, false)
|
||||
: matchers.some(matcher => matcher.match(relativePath));
|
||||
|
||||
return matchesPattern && !configs.isFileIgnored(entry.path);
|
||||
}
|
||||
|
||||
})).map(entry => entry.path);
|
||||
|
||||
// now check to see if we have any unmatched patterns
|
||||
if (errorOnUnmatchedPattern && unmatchedPatterns.size > 0) {
|
||||
throw new UnmatchedSearchPatternsError({
|
||||
basePath,
|
||||
unmatchedPatterns: [...unmatchedPatterns].map(
|
||||
pattern => relativeToPatterns.get(pattern)
|
||||
),
|
||||
patterns,
|
||||
rawPatterns
|
||||
});
|
||||
}
|
||||
|
||||
return filePaths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if there are any ignored results for a given search. This
|
||||
* happens either when there are unmatched patterns during a search or if
|
||||
* a search returns no results.
|
||||
* @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
|
||||
* that were used in the original search.
|
||||
* @param {Array<string>} options.rawPatterns An array of glob patterns
|
||||
* as the user inputted them. Used for errors.
|
||||
* @param {Array<string>} options.patternsToCheck An array of glob patterns
|
||||
* to use for this check.
|
||||
* @returns {void}
|
||||
* @throws {NoFilesFoundError} If there is a pattern that doesn't match
|
||||
* any files and `errorOnUnmatchedPattern` is true.
|
||||
* @throws {AllFilesIgnoredError} If there is a pattern that matches files
|
||||
* when there are no ignores.
|
||||
*/
|
||||
async function checkForIgnoredResults({
|
||||
basePath,
|
||||
patterns,
|
||||
rawPatterns,
|
||||
patternsToCheck = patterns
|
||||
}) {
|
||||
|
||||
for (const pattern of patternsToCheck) {
|
||||
|
||||
const patternHasMatch = await globMatch({
|
||||
basePath,
|
||||
pattern
|
||||
});
|
||||
|
||||
if (patternHasMatch) {
|
||||
throw new AllFilesIgnoredError(
|
||||
rawPatterns[patterns.indexOf(pattern)]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// if we get here there are truly no matches
|
||||
throw new NoFilesFoundError(
|
||||
rawPatterns[patterns.indexOf(patternsToCheck[0])],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs multiple glob searches in parallel.
|
||||
* @param {Object} options The options for this function.
|
||||
* @param {Map<string,GlobSearch>} options.searches
|
||||
* An array of glob patterns to match.
|
||||
* @param {FlatConfigArray} options.configs The config array to use for
|
||||
* determining what to ignore.
|
||||
* @param {boolean} options.errorOnUnmatchedPattern Determines if an
|
||||
* unmatched glob pattern should throw an error.
|
||||
* @returns {Promise<Array<string>>} An array of matching file paths
|
||||
* or an empty array if there are no matches.
|
||||
*/
|
||||
async function globMultiSearch({ searches, configs, errorOnUnmatchedPattern }) {
|
||||
|
||||
/*
|
||||
* For convenience, we normalized the search map into an array of objects.
|
||||
* Next, we filter out all searches that have no patterns. This happens
|
||||
* primarily for the cwd, which is prepopulated in the searches map as an
|
||||
* optimization. However, if it has no patterns, it means all patterns
|
||||
* occur outside of the cwd and we can safely filter out that search.
|
||||
*/
|
||||
const normalizedSearches = [...searches].map(
|
||||
([basePath, { patterns, rawPatterns }]) => ({ basePath, patterns, rawPatterns })
|
||||
).filter(({ patterns }) => patterns.length > 0);
|
||||
|
||||
const results = await Promise.allSettled(
|
||||
normalizedSearches.map(
|
||||
({ basePath, patterns, rawPatterns }) => globSearch({
|
||||
basePath,
|
||||
patterns,
|
||||
rawPatterns,
|
||||
configs,
|
||||
errorOnUnmatchedPattern
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
const filePaths = [];
|
||||
|
||||
for (let i = 0; i < results.length; i++) {
|
||||
|
||||
const result = results[i];
|
||||
const currentSearch = normalizedSearches[i];
|
||||
|
||||
if (result.status === "fulfilled") {
|
||||
|
||||
// if the search was successful just add the results
|
||||
if (result.value.length > 0) {
|
||||
filePaths.push(...result.value);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// if we make it here then there was an error
|
||||
const error = result.reason;
|
||||
|
||||
// unexpected errors should be re-thrown
|
||||
if (!error.basePath) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (errorOnUnmatchedPattern) {
|
||||
|
||||
await checkForIgnoredResults({
|
||||
...currentSearch,
|
||||
patternsToCheck: error.patternsToCheck
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return [...new Set(filePaths)];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches a directory looking for matching glob patterns. This uses
|
||||
* the config array's logic to determine if a directory or file should
|
||||
@@ -335,47 +687,17 @@ async function findFiles({
|
||||
}
|
||||
});
|
||||
|
||||
const globbyResults = await globMultiSearch({
|
||||
searches,
|
||||
configs
|
||||
});
|
||||
|
||||
// if there are no results, tell the user why
|
||||
if (!results.length && !globbyResults.length) {
|
||||
|
||||
for (const [basePath, { patterns: patternsToCheck, rawPatterns: patternsToReport }] of searches) {
|
||||
|
||||
let index = 0;
|
||||
|
||||
// try globby without ignoring anything
|
||||
for (const patternToCheck of patternsToCheck) {
|
||||
|
||||
// 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++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// there were patterns that didn't match anything, tell the user
|
||||
if (errorOnUnmatchedPattern && missingPatterns.length) {
|
||||
throw new NoFilesFoundError(missingPatterns[0], globInputPaths);
|
||||
}
|
||||
|
||||
// now we are safe to do the search
|
||||
const globbyResults = await globMultiSearch({
|
||||
searches,
|
||||
configs,
|
||||
errorOnUnmatchedPattern
|
||||
});
|
||||
|
||||
return [
|
||||
...results,
|
||||
|
||||
48
tools/node_modules/eslint/lib/eslint/flat-eslint.js
generated
vendored
48
tools/node_modules/eslint/lib/eslint/flat-eslint.js
generated
vendored
@@ -161,6 +161,16 @@ function createRulesMeta(rules) {
|
||||
}, {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the absolute path of a file named `"__placeholder__.js"` in a given directory.
|
||||
* This is used as a replacement for a missing file path.
|
||||
* @param {string} cwd An absolute directory path.
|
||||
* @returns {string} The absolute path of a file named `"__placeholder__.js"` in the given directory.
|
||||
*/
|
||||
function getPlaceholderPath(cwd) {
|
||||
return path.join(cwd, "__placeholder__.js");
|
||||
}
|
||||
|
||||
/** @type {WeakMap<ExtractedConfig, DeprecatedRuleInfo[]>} */
|
||||
const usedDeprecatedRulesCache = new WeakMap();
|
||||
|
||||
@@ -177,7 +187,7 @@ function getOrFindUsedDeprecatedRules(eslint, maybeFilePath) {
|
||||
} = privateMembers.get(eslint);
|
||||
const filePath = path.isAbsolute(maybeFilePath)
|
||||
? maybeFilePath
|
||||
: path.join(cwd, "__placeholder__.js");
|
||||
: getPlaceholderPath(cwd);
|
||||
const config = configs.getConfig(filePath);
|
||||
|
||||
// Most files use the same config, so cache it.
|
||||
@@ -422,7 +432,7 @@ function verifyText({
|
||||
* `config.extractConfig(filePath)` requires an absolute path, but `linter`
|
||||
* doesn't know CWD, so it gives `linter` an absolute path always.
|
||||
*/
|
||||
const filePathToVerify = filePath === "<text>" ? path.join(cwd, "__placeholder__.js") : filePath;
|
||||
const filePathToVerify = filePath === "<text>" ? getPlaceholderPath(cwd) : filePath;
|
||||
const { fixed, messages, output } = linter.verifyAndFix(
|
||||
text,
|
||||
configs,
|
||||
@@ -519,6 +529,14 @@ function *iterateRuleDeprecationWarnings(configs) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an error to be thrown when an array of results passed to `getRulesMetaForResults` was not created by the current engine.
|
||||
* @returns {TypeError} An error object.
|
||||
*/
|
||||
function createExtraneousResultsError() {
|
||||
return new TypeError("Results object was not created from this ESLint instance.");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main API
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -655,7 +673,10 @@ class FlatESLint {
|
||||
}
|
||||
|
||||
const resultRules = new Map();
|
||||
const { configs } = privateMembers.get(this);
|
||||
const {
|
||||
configs,
|
||||
options: { cwd }
|
||||
} = privateMembers.get(this);
|
||||
|
||||
/*
|
||||
* We can only accurately return rules meta information for linting results if the
|
||||
@@ -664,7 +685,7 @@ class FlatESLint {
|
||||
* to let the user know we can't do anything here.
|
||||
*/
|
||||
if (!configs) {
|
||||
throw new TypeError("Results object was not created from this ESLint instance.");
|
||||
throw createExtraneousResultsError();
|
||||
}
|
||||
|
||||
for (const result of results) {
|
||||
@@ -673,13 +694,7 @@ class FlatESLint {
|
||||
* Normalize filename for <text>.
|
||||
*/
|
||||
const filePath = result.filePath === "<text>"
|
||||
? "__placeholder__.js" : result.filePath;
|
||||
|
||||
/*
|
||||
* All of the plugin and rule information is contained within the
|
||||
* calculated config for the given file.
|
||||
*/
|
||||
const config = configs.getConfig(filePath);
|
||||
? getPlaceholderPath(cwd) : result.filePath;
|
||||
const allMessages = result.messages.concat(result.suppressedMessages);
|
||||
|
||||
for (const { ruleId } of allMessages) {
|
||||
@@ -687,6 +702,15 @@ class FlatESLint {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* All of the plugin and rule information is contained within the
|
||||
* calculated config for the given file.
|
||||
*/
|
||||
const config = configs.getConfig(filePath);
|
||||
|
||||
if (!config) {
|
||||
throw createExtraneousResultsError();
|
||||
}
|
||||
const rule = getRuleFromConfig(ruleId, config);
|
||||
|
||||
// ensure the rule exists
|
||||
@@ -1024,7 +1048,7 @@ class FlatESLint {
|
||||
const npmFormat = naming.normalizePackageName(normalizedFormatName, "eslint-formatter");
|
||||
|
||||
// TODO: This is pretty dirty...would be nice to clean up at some point.
|
||||
formatterPath = ModuleResolver.resolve(npmFormat, path.join(cwd, "__placeholder__.js"));
|
||||
formatterPath = ModuleResolver.resolve(npmFormat, getPlaceholderPath(cwd));
|
||||
} catch {
|
||||
formatterPath = path.resolve(__dirname, "../", "cli-engine", "formatters", `${normalizedFormatName}.js`);
|
||||
}
|
||||
|
||||
4
tools/node_modules/eslint/lib/rules/comma-dangle.js
generated
vendored
4
tools/node_modules/eslint/lib/rules/comma-dangle.js
generated
vendored
@@ -50,7 +50,7 @@ function normalizeOptions(optionValue, ecmaVersion) {
|
||||
objects: optionValue,
|
||||
imports: optionValue,
|
||||
exports: optionValue,
|
||||
functions: (!ecmaVersion || ecmaVersion < 8) ? "ignore" : optionValue
|
||||
functions: ecmaVersion < 2017 ? "ignore" : optionValue
|
||||
};
|
||||
}
|
||||
if (typeof optionValue === "object" && optionValue !== null) {
|
||||
@@ -134,7 +134,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const options = normalizeOptions(context.options[0], context.parserOptions.ecmaVersion);
|
||||
const options = normalizeOptions(context.options[0], context.languageOptions.ecmaVersion);
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
|
||||
|
||||
4
tools/node_modules/eslint/lib/rules/func-name-matching.js
generated
vendored
4
tools/node_modules/eslint/lib/rules/func-name-matching.js
generated
vendored
@@ -44,7 +44,7 @@ function isModuleExports(pattern) {
|
||||
* @returns {boolean} True if the string is a valid identifier
|
||||
*/
|
||||
function isIdentifier(name, ecmaVersion) {
|
||||
if (ecmaVersion >= 6) {
|
||||
if (ecmaVersion >= 2015) {
|
||||
return esutils.keyword.isIdentifierES6(name);
|
||||
}
|
||||
return esutils.keyword.isIdentifierES5(name);
|
||||
@@ -104,7 +104,7 @@ module.exports = {
|
||||
const nameMatches = typeof context.options[0] === "string" ? context.options[0] : "always";
|
||||
const considerPropertyDescriptor = options.considerPropertyDescriptor;
|
||||
const includeModuleExports = options.includeCommonJSModuleExports;
|
||||
const ecmaVersion = context.parserOptions && context.parserOptions.ecmaVersion ? context.parserOptions.ecmaVersion : 5;
|
||||
const ecmaVersion = context.languageOptions.ecmaVersion;
|
||||
|
||||
/**
|
||||
* Check whether node is a certain CallExpression.
|
||||
|
||||
2
tools/node_modules/eslint/lib/rules/index.js
generated
vendored
2
tools/node_modules/eslint/lib/rules/index.js
generated
vendored
@@ -123,6 +123,7 @@ module.exports = new LazyLoadingRuleMap(Object.entries({
|
||||
"no-empty-character-class": () => require("./no-empty-character-class"),
|
||||
"no-empty-function": () => require("./no-empty-function"),
|
||||
"no-empty-pattern": () => require("./no-empty-pattern"),
|
||||
"no-empty-static-block": () => require("./no-empty-static-block"),
|
||||
"no-eq-null": () => require("./no-eq-null"),
|
||||
"no-eval": () => require("./no-eval"),
|
||||
"no-ex-assign": () => require("./no-ex-assign"),
|
||||
@@ -167,6 +168,7 @@ module.exports = new LazyLoadingRuleMap(Object.entries({
|
||||
"no-nested-ternary": () => require("./no-nested-ternary"),
|
||||
"no-new": () => require("./no-new"),
|
||||
"no-new-func": () => require("./no-new-func"),
|
||||
"no-new-native-nonconstructor": () => require("./no-new-native-nonconstructor"),
|
||||
"no-new-object": () => require("./no-new-object"),
|
||||
"no-new-require": () => require("./no-new-require"),
|
||||
"no-new-symbol": () => require("./no-new-symbol"),
|
||||
|
||||
47
tools/node_modules/eslint/lib/rules/no-empty-static-block.js
generated
vendored
Normal file
47
tools/node_modules/eslint/lib/rules/no-empty-static-block.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @fileoverview Rule to disallow empty static blocks.
|
||||
* @author Sosuke Suzuki
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "Disallow empty static blocks",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/no-empty-static-block"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
unexpected: "Unexpected empty static block."
|
||||
}
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
|
||||
return {
|
||||
StaticBlock(node) {
|
||||
if (node.body.length === 0) {
|
||||
const closingBrace = sourceCode.getLastToken(node);
|
||||
|
||||
if (sourceCode.getCommentsBefore(closingBrace).length === 0) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpected"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
21
tools/node_modules/eslint/lib/rules/no-empty.js
generated
vendored
21
tools/node_modules/eslint/lib/rules/no-empty.js
generated
vendored
@@ -17,6 +17,7 @@ const astUtils = require("./utils/ast-utils");
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
hasSuggestions: true,
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
@@ -39,7 +40,8 @@ module.exports = {
|
||||
],
|
||||
|
||||
messages: {
|
||||
unexpected: "Empty {{type}} statement."
|
||||
unexpected: "Empty {{type}} statement.",
|
||||
suggestComment: "Add comment inside empty {{type}} statement."
|
||||
}
|
||||
},
|
||||
|
||||
@@ -71,7 +73,22 @@ module.exports = {
|
||||
return;
|
||||
}
|
||||
|
||||
context.report({ node, messageId: "unexpected", data: { type: "block" } });
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpected",
|
||||
data: { type: "block" },
|
||||
suggest: [
|
||||
{
|
||||
messageId: "suggestComment",
|
||||
data: { type: "block" },
|
||||
fix(fixer) {
|
||||
const range = [node.range[0] + 1, node.range[1] - 1];
|
||||
|
||||
return fixer.replaceTextRange(range, " /* empty */ ");
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
},
|
||||
|
||||
SwitchStatement(node) {
|
||||
|
||||
8
tools/node_modules/eslint/lib/rules/no-misleading-character-class.js
generated
vendored
8
tools/node_modules/eslint/lib/rules/no-misleading-character-class.js
generated
vendored
@@ -193,15 +193,15 @@ module.exports = {
|
||||
* ecmaVersion doesn't support the `u` flag.
|
||||
*/
|
||||
function isValidWithUnicodeFlag(pattern) {
|
||||
const { ecmaVersion } = context.parserOptions;
|
||||
const { ecmaVersion } = context.languageOptions;
|
||||
|
||||
// ecmaVersion is unknown or it doesn't support the 'u' flag
|
||||
if (typeof ecmaVersion !== "number" || ecmaVersion <= 5) {
|
||||
// ecmaVersion <= 5 doesn't support the 'u' flag
|
||||
if (ecmaVersion <= 5) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const validator = new RegExpValidator({
|
||||
ecmaVersion: Math.min(ecmaVersion + 2009, REGEXPP_LATEST_ECMA_VERSION)
|
||||
ecmaVersion: Math.min(ecmaVersion, REGEXPP_LATEST_ECMA_VERSION)
|
||||
});
|
||||
|
||||
try {
|
||||
|
||||
64
tools/node_modules/eslint/lib/rules/no-new-native-nonconstructor.js
generated
vendored
Normal file
64
tools/node_modules/eslint/lib/rules/no-new-native-nonconstructor.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @fileoverview Rule to disallow use of the new operator with global non-constructor functions
|
||||
* @author Sosuke Suzuki
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const nonConstructorGlobalFunctionNames = ["Symbol", "BigInt"];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "problem",
|
||||
|
||||
docs: {
|
||||
description: "Disallow `new` operators with global non-constructor functions",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/no-new-native-nonconstructor"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
noNewNonconstructor: "`{{name}}` cannot be called as a constructor."
|
||||
}
|
||||
},
|
||||
|
||||
create(context) {
|
||||
|
||||
return {
|
||||
"Program:exit"() {
|
||||
const globalScope = context.getScope();
|
||||
|
||||
for (const nonConstructorName of nonConstructorGlobalFunctionNames) {
|
||||
const variable = globalScope.set.get(nonConstructorName);
|
||||
|
||||
if (variable && variable.defs.length === 0) {
|
||||
variable.references.forEach(ref => {
|
||||
const node = ref.identifier;
|
||||
const parent = node.parent;
|
||||
|
||||
if (parent && parent.type === "NewExpression" && parent.callee === node) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "noNewNonconstructor",
|
||||
data: { name: nonConstructorName }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
8
tools/node_modules/eslint/lib/rules/prefer-regex-literals.js
generated
vendored
8
tools/node_modules/eslint/lib/rules/prefer-regex-literals.js
generated
vendored
@@ -248,14 +248,14 @@ module.exports = {
|
||||
|
||||
/**
|
||||
* Returns a ecmaVersion compatible for regexpp.
|
||||
* @param {any} ecmaVersion The ecmaVersion to convert.
|
||||
* @param {number} ecmaVersion The ecmaVersion to convert.
|
||||
* @returns {import("regexpp/ecma-versions").EcmaVersion} The resulting ecmaVersion compatible for regexpp.
|
||||
*/
|
||||
function getRegexppEcmaVersion(ecmaVersion) {
|
||||
if (typeof ecmaVersion !== "number" || ecmaVersion <= 5) {
|
||||
if (ecmaVersion <= 5) {
|
||||
return 5;
|
||||
}
|
||||
return Math.min(ecmaVersion + 2009, REGEXPP_LATEST_ECMA_VERSION);
|
||||
return Math.min(ecmaVersion, REGEXPP_LATEST_ECMA_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,7 +320,7 @@ module.exports = {
|
||||
flags = getStringValue(node.arguments[1]);
|
||||
}
|
||||
|
||||
const regexppEcmaVersion = getRegexppEcmaVersion(context.parserOptions.ecmaVersion);
|
||||
const regexppEcmaVersion = getRegexppEcmaVersion(context.languageOptions.ecmaVersion);
|
||||
const RegExpValidatorInstance = new RegExpValidator({ ecmaVersion: regexppEcmaVersion });
|
||||
|
||||
try {
|
||||
|
||||
2
tools/node_modules/eslint/node_modules/@babel/compat-data/package.json
generated
vendored
2
tools/node_modules/eslint/node_modules/@babel/compat-data/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/compat-data",
|
||||
"version": "7.20.0",
|
||||
"version": "7.20.1",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"license": "MIT",
|
||||
"description": "",
|
||||
|
||||
64
tools/node_modules/eslint/node_modules/@babel/core/lib/config/caching.js
generated
vendored
64
tools/node_modules/eslint/node_modules/@babel/core/lib/config/caching.js
generated
vendored
@@ -8,21 +8,15 @@ exports.makeStrongCache = makeStrongCache;
|
||||
exports.makeStrongCacheSync = makeStrongCacheSync;
|
||||
exports.makeWeakCache = makeWeakCache;
|
||||
exports.makeWeakCacheSync = makeWeakCacheSync;
|
||||
|
||||
function _gensync() {
|
||||
const data = require("gensync");
|
||||
|
||||
_gensync = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _async = require("../gensync-utils/async");
|
||||
|
||||
var _util = require("./util");
|
||||
|
||||
const synchronize = gen => {
|
||||
return _gensync()(gen).sync;
|
||||
};
|
||||
@@ -30,19 +24,15 @@ const synchronize = gen => {
|
||||
function* genTrue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function makeWeakCache(handler) {
|
||||
return makeCachedFunction(WeakMap, handler);
|
||||
}
|
||||
|
||||
function makeWeakCacheSync(handler) {
|
||||
return synchronize(makeWeakCache(handler));
|
||||
}
|
||||
|
||||
function makeStrongCache(handler) {
|
||||
return makeCachedFunction(Map, handler);
|
||||
}
|
||||
|
||||
function makeStrongCacheSync(handler) {
|
||||
return synchronize(makeStrongCache(handler));
|
||||
}
|
||||
@@ -60,7 +50,6 @@ function makeCachedFunction(CallCache, handler) {
|
||||
const handlerResult = handler(arg, cache);
|
||||
let finishLock;
|
||||
let value;
|
||||
|
||||
if ((0, _util.isIterableIterator)(handlerResult)) {
|
||||
value = yield* (0, _async.onFirstPause)(handlerResult, () => {
|
||||
finishLock = setupAsyncLocks(cache, futureCache, arg);
|
||||
@@ -68,21 +57,16 @@ function makeCachedFunction(CallCache, handler) {
|
||||
} else {
|
||||
value = handlerResult;
|
||||
}
|
||||
|
||||
updateFunctionCache(callCache, cache, arg, value);
|
||||
|
||||
if (finishLock) {
|
||||
futureCache.delete(arg);
|
||||
finishLock.release(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
function* getCachedValue(cache, arg, data) {
|
||||
const cachedValue = cache.get(arg);
|
||||
|
||||
if (cachedValue) {
|
||||
for (const {
|
||||
value,
|
||||
@@ -94,23 +78,18 @@ function* getCachedValue(cache, arg, data) {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
valid: false,
|
||||
value: null
|
||||
};
|
||||
}
|
||||
|
||||
function* getCachedValueOrWait(asyncContext, callCache, futureCache, arg, data) {
|
||||
const cached = yield* getCachedValue(callCache, arg, data);
|
||||
|
||||
if (cached.valid) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
if (asyncContext) {
|
||||
const cached = yield* getCachedValue(futureCache, arg, data);
|
||||
|
||||
if (cached.valid) {
|
||||
const value = yield* (0, _async.waitFor)(cached.value.promise);
|
||||
return {
|
||||
@@ -119,24 +98,20 @@ function* getCachedValueOrWait(asyncContext, callCache, futureCache, arg, data)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
valid: false,
|
||||
value: null
|
||||
};
|
||||
}
|
||||
|
||||
function setupAsyncLocks(config, futureCache, arg) {
|
||||
const finishLock = new Lock();
|
||||
updateFunctionCache(futureCache, config, arg, finishLock);
|
||||
return finishLock;
|
||||
}
|
||||
|
||||
function updateFunctionCache(cache, config, arg, value) {
|
||||
if (!config.configured()) config.forever();
|
||||
let cachedValue = cache.get(arg);
|
||||
config.deactivate();
|
||||
|
||||
switch (config.mode()) {
|
||||
case "forever":
|
||||
cachedValue = [{
|
||||
@@ -145,7 +120,6 @@ function updateFunctionCache(cache, config, arg, value) {
|
||||
}];
|
||||
cache.set(arg, cachedValue);
|
||||
break;
|
||||
|
||||
case "invalidate":
|
||||
cachedValue = [{
|
||||
value,
|
||||
@@ -153,7 +127,6 @@ function updateFunctionCache(cache, config, arg, value) {
|
||||
}];
|
||||
cache.set(arg, cachedValue);
|
||||
break;
|
||||
|
||||
case "valid":
|
||||
if (cachedValue) {
|
||||
cachedValue.push({
|
||||
@@ -167,10 +140,8 @@ function updateFunctionCache(cache, config, arg, value) {
|
||||
}];
|
||||
cache.set(arg, cachedValue);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class CacheConfigurator {
|
||||
constructor(data) {
|
||||
this._active = true;
|
||||
@@ -182,114 +153,86 @@ class CacheConfigurator {
|
||||
this._data = void 0;
|
||||
this._data = data;
|
||||
}
|
||||
|
||||
simple() {
|
||||
return makeSimpleConfigurator(this);
|
||||
}
|
||||
|
||||
mode() {
|
||||
if (this._never) return "never";
|
||||
if (this._forever) return "forever";
|
||||
if (this._invalidate) return "invalidate";
|
||||
return "valid";
|
||||
}
|
||||
|
||||
forever() {
|
||||
if (!this._active) {
|
||||
throw new Error("Cannot change caching after evaluation has completed.");
|
||||
}
|
||||
|
||||
if (this._never) {
|
||||
throw new Error("Caching has already been configured with .never()");
|
||||
}
|
||||
|
||||
this._forever = true;
|
||||
this._configured = true;
|
||||
}
|
||||
|
||||
never() {
|
||||
if (!this._active) {
|
||||
throw new Error("Cannot change caching after evaluation has completed.");
|
||||
}
|
||||
|
||||
if (this._forever) {
|
||||
throw new Error("Caching has already been configured with .forever()");
|
||||
}
|
||||
|
||||
this._never = true;
|
||||
this._configured = true;
|
||||
}
|
||||
|
||||
using(handler) {
|
||||
if (!this._active) {
|
||||
throw new Error("Cannot change caching after evaluation has completed.");
|
||||
}
|
||||
|
||||
if (this._never || this._forever) {
|
||||
throw new Error("Caching has already been configured with .never or .forever()");
|
||||
}
|
||||
|
||||
this._configured = true;
|
||||
const key = handler(this._data);
|
||||
const fn = (0, _async.maybeAsync)(handler, `You appear to be using an async cache handler, but Babel has been called synchronously`);
|
||||
|
||||
if ((0, _async.isThenable)(key)) {
|
||||
return key.then(key => {
|
||||
this._pairs.push([key, fn]);
|
||||
|
||||
return key;
|
||||
});
|
||||
}
|
||||
|
||||
this._pairs.push([key, fn]);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
invalidate(handler) {
|
||||
this._invalidate = true;
|
||||
return this.using(handler);
|
||||
}
|
||||
|
||||
validator() {
|
||||
const pairs = this._pairs;
|
||||
return function* (data) {
|
||||
for (const [key, fn] of pairs) {
|
||||
if (key !== (yield* fn(data))) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
deactivate() {
|
||||
this._active = false;
|
||||
}
|
||||
|
||||
configured() {
|
||||
return this._configured;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function makeSimpleConfigurator(cache) {
|
||||
function cacheFn(val) {
|
||||
if (typeof val === "boolean") {
|
||||
if (val) cache.forever();else cache.never();
|
||||
return;
|
||||
}
|
||||
|
||||
return cache.using(() => assertSimpleType(val()));
|
||||
}
|
||||
|
||||
cacheFn.forever = () => cache.forever();
|
||||
|
||||
cacheFn.never = () => cache.never();
|
||||
|
||||
cacheFn.using = cb => cache.using(() => assertSimpleType(cb()));
|
||||
|
||||
cacheFn.invalidate = cb => cache.invalidate(() => assertSimpleType(cb()));
|
||||
|
||||
return cacheFn;
|
||||
}
|
||||
|
||||
@@ -297,14 +240,11 @@ function assertSimpleType(value) {
|
||||
if ((0, _async.isThenable)(value)) {
|
||||
throw new Error(`You appear to be using an async cache handler, ` + `which your current version of Babel does not support. ` + `We may add support for this in the future, ` + `but if you're on the most recent version of @babel/core and still ` + `seeing this error, then you'll need to synchronously handle your caching logic.`);
|
||||
}
|
||||
|
||||
if (value != null && typeof value !== "string" && typeof value !== "boolean" && typeof value !== "number") {
|
||||
throw new Error("Cache keys must be either string, boolean, number, null, or undefined.");
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
class Lock {
|
||||
constructor() {
|
||||
this.released = false;
|
||||
@@ -314,15 +254,11 @@ class Lock {
|
||||
this._resolve = resolve;
|
||||
});
|
||||
}
|
||||
|
||||
release(value) {
|
||||
this.released = true;
|
||||
|
||||
this._resolve(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=caching.js.map
|
||||
|
||||
100
tools/node_modules/eslint/node_modules/@babel/core/lib/config/config-chain.js
generated
vendored
100
tools/node_modules/eslint/node_modules/@babel/core/lib/config/config-chain.js
generated
vendored
@@ -6,45 +6,30 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.buildPresetChain = buildPresetChain;
|
||||
exports.buildPresetChainWalker = void 0;
|
||||
exports.buildRootChain = buildRootChain;
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _debug() {
|
||||
const data = require("debug");
|
||||
|
||||
_debug = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _options = require("./validation/options");
|
||||
|
||||
var _patternToRegex = require("./pattern-to-regex");
|
||||
|
||||
var _printer = require("./printer");
|
||||
|
||||
var _rewriteStackTrace = require("../errors/rewrite-stack-trace");
|
||||
|
||||
var _configError = require("../errors/config-error");
|
||||
|
||||
var _files = require("./files");
|
||||
|
||||
var _caching = require("./caching");
|
||||
|
||||
var _configDescriptors = require("./config-descriptors");
|
||||
|
||||
const debug = _debug()("babel:config:config-chain");
|
||||
|
||||
function* buildPresetChain(arg, context) {
|
||||
const chain = yield* buildPresetChainWalker(arg, context);
|
||||
if (!chain) return null;
|
||||
@@ -55,7 +40,6 @@ function* buildPresetChain(arg, context) {
|
||||
files: new Set()
|
||||
};
|
||||
}
|
||||
|
||||
const buildPresetChainWalker = makeChainWalker({
|
||||
root: preset => loadPresetDescriptors(preset),
|
||||
env: (preset, envName) => loadPresetEnvDescriptors(preset)(envName),
|
||||
@@ -68,7 +52,6 @@ const loadPresetDescriptors = (0, _caching.makeWeakCacheSync)(preset => buildRoo
|
||||
const loadPresetEnvDescriptors = (0, _caching.makeWeakCacheSync)(preset => (0, _caching.makeStrongCacheSync)(envName => buildEnvDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, envName)));
|
||||
const loadPresetOverridesDescriptors = (0, _caching.makeWeakCacheSync)(preset => (0, _caching.makeStrongCacheSync)(index => buildOverrideDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, index)));
|
||||
const loadPresetOverridesEnvDescriptors = (0, _caching.makeWeakCacheSync)(preset => (0, _caching.makeStrongCacheSync)(index => (0, _caching.makeStrongCacheSync)(envName => buildOverrideEnvDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, index, envName))));
|
||||
|
||||
function* buildRootChain(opts, context) {
|
||||
let configReport, babelRcReport;
|
||||
const programmaticLogger = new _printer.ConfigPrinter();
|
||||
@@ -79,13 +62,11 @@ function* buildRootChain(opts, context) {
|
||||
if (!programmaticChain) return null;
|
||||
const programmaticReport = yield* programmaticLogger.output();
|
||||
let configFile;
|
||||
|
||||
if (typeof opts.configFile === "string") {
|
||||
configFile = yield* (0, _files.loadConfig)(opts.configFile, context.cwd, context.envName, context.caller);
|
||||
} else if (opts.configFile !== false) {
|
||||
configFile = yield* (0, _files.findRootConfig)(context.root, context.envName, context.caller);
|
||||
}
|
||||
|
||||
let {
|
||||
babelrc,
|
||||
babelrcRoots
|
||||
@@ -93,7 +74,6 @@ function* buildRootChain(opts, context) {
|
||||
let babelrcRootsDirectory = context.cwd;
|
||||
const configFileChain = emptyChain();
|
||||
const configFileLogger = new _printer.ConfigPrinter();
|
||||
|
||||
if (configFile) {
|
||||
const validatedFile = validateConfigFile(configFile);
|
||||
const result = yield* loadFileChain(validatedFile, context, undefined, configFileLogger);
|
||||
@@ -103,41 +83,32 @@ function* buildRootChain(opts, context) {
|
||||
if (babelrc === undefined) {
|
||||
babelrc = validatedFile.options.babelrc;
|
||||
}
|
||||
|
||||
if (babelrcRoots === undefined) {
|
||||
babelrcRootsDirectory = validatedFile.dirname;
|
||||
babelrcRoots = validatedFile.options.babelrcRoots;
|
||||
}
|
||||
|
||||
mergeChain(configFileChain, result);
|
||||
}
|
||||
|
||||
let ignoreFile, babelrcFile;
|
||||
let isIgnored = false;
|
||||
const fileChain = emptyChain();
|
||||
|
||||
if ((babelrc === true || babelrc === undefined) && typeof context.filename === "string") {
|
||||
const pkgData = yield* (0, _files.findPackageData)(context.filename);
|
||||
|
||||
if (pkgData && babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory)) {
|
||||
({
|
||||
ignore: ignoreFile,
|
||||
config: babelrcFile
|
||||
} = yield* (0, _files.findRelativeConfig)(pkgData, context.envName, context.caller));
|
||||
|
||||
if (ignoreFile) {
|
||||
fileChain.files.add(ignoreFile.filepath);
|
||||
}
|
||||
|
||||
if (ignoreFile && shouldIgnore(context, ignoreFile.ignore, null, ignoreFile.dirname)) {
|
||||
isIgnored = true;
|
||||
}
|
||||
|
||||
if (babelrcFile && !isIgnored) {
|
||||
const validatedFile = validateBabelrcFile(babelrcFile);
|
||||
const babelrcLogger = new _printer.ConfigPrinter();
|
||||
const result = yield* loadFileChain(validatedFile, context, undefined, babelrcLogger);
|
||||
|
||||
if (!result) {
|
||||
isIgnored = true;
|
||||
} else {
|
||||
@@ -145,17 +116,15 @@ function* buildRootChain(opts, context) {
|
||||
mergeChain(fileChain, result);
|
||||
}
|
||||
}
|
||||
|
||||
if (babelrcFile && isIgnored) {
|
||||
fileChain.files.add(babelrcFile.filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (context.showConfig) {
|
||||
console.log(`Babel configs on "${context.filename}" (ascending priority):\n` + [configReport, babelRcReport, programmaticReport].filter(x => !!x).join("\n\n") + "\n-----End Babel configs-----");
|
||||
console.log(`Babel configs on "${context.filename}" (ascending priority):\n` +
|
||||
[configReport, babelRcReport, programmaticReport].filter(x => !!x).join("\n\n") + "\n-----End Babel configs-----");
|
||||
}
|
||||
|
||||
const chain = mergeChain(mergeChain(mergeChain(emptyChain(), configFileChain), fileChain), programmaticChain);
|
||||
return {
|
||||
plugins: isIgnored ? [] : dedupDescriptors(chain.plugins),
|
||||
@@ -168,7 +137,6 @@ function* buildRootChain(opts, context) {
|
||||
files: chain.files
|
||||
};
|
||||
}
|
||||
|
||||
function babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory) {
|
||||
if (typeof babelrcRoots === "boolean") return babelrcRoots;
|
||||
const absoluteRoot = context.root;
|
||||
@@ -176,13 +144,10 @@ function babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirector
|
||||
if (babelrcRoots === undefined) {
|
||||
return pkgData.directories.indexOf(absoluteRoot) !== -1;
|
||||
}
|
||||
|
||||
let babelrcPatterns = babelrcRoots;
|
||||
|
||||
if (!Array.isArray(babelrcPatterns)) {
|
||||
babelrcPatterns = [babelrcPatterns];
|
||||
}
|
||||
|
||||
babelrcPatterns = babelrcPatterns.map(pat => {
|
||||
return typeof pat === "string" ? _path().resolve(babelrcRootsDirectory, pat) : pat;
|
||||
});
|
||||
@@ -190,18 +155,15 @@ function babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirector
|
||||
if (babelrcPatterns.length === 1 && babelrcPatterns[0] === absoluteRoot) {
|
||||
return pkgData.directories.indexOf(absoluteRoot) !== -1;
|
||||
}
|
||||
|
||||
return babelrcPatterns.some(pat => {
|
||||
if (typeof pat === "string") {
|
||||
pat = (0, _patternToRegex.default)(pat, babelrcRootsDirectory);
|
||||
}
|
||||
|
||||
return pkgData.directories.some(directory => {
|
||||
return matchPattern(pat, babelrcRootsDirectory, directory, context);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const validateConfigFile = (0, _caching.makeWeakCacheSync)(file => ({
|
||||
filepath: file.filepath,
|
||||
dirname: file.dirname,
|
||||
@@ -217,6 +179,7 @@ const validateExtendFile = (0, _caching.makeWeakCacheSync)(file => ({
|
||||
dirname: file.dirname,
|
||||
options: (0, _options.validate)("extendsfile", file.options, file.filepath)
|
||||
}));
|
||||
|
||||
const loadProgrammaticChain = makeChainWalker({
|
||||
root: input => buildRootDescriptors(input, "base", _configDescriptors.createCachedDescriptors),
|
||||
env: (input, envName) => buildEnvDescriptors(input, "base", _configDescriptors.createCachedDescriptors, envName),
|
||||
@@ -224,6 +187,7 @@ const loadProgrammaticChain = makeChainWalker({
|
||||
overridesEnv: (input, index, envName) => buildOverrideEnvDescriptors(input, "base", _configDescriptors.createCachedDescriptors, index, envName),
|
||||
createLogger: (input, context, baseLogger) => buildProgrammaticLogger(input, context, baseLogger)
|
||||
});
|
||||
|
||||
const loadFileChainWalker = makeChainWalker({
|
||||
root: file => loadFileDescriptors(file),
|
||||
env: (file, envName) => loadFileEnvDescriptors(file)(envName),
|
||||
@@ -231,51 +195,40 @@ const loadFileChainWalker = makeChainWalker({
|
||||
overridesEnv: (file, index, envName) => loadFileOverridesEnvDescriptors(file)(index)(envName),
|
||||
createLogger: (file, context, baseLogger) => buildFileLogger(file.filepath, context, baseLogger)
|
||||
});
|
||||
|
||||
function* loadFileChain(input, context, files, baseLogger) {
|
||||
const chain = yield* loadFileChainWalker(input, context, files, baseLogger);
|
||||
|
||||
if (chain) {
|
||||
chain.files.add(input.filepath);
|
||||
}
|
||||
|
||||
return chain;
|
||||
}
|
||||
|
||||
const loadFileDescriptors = (0, _caching.makeWeakCacheSync)(file => buildRootDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors));
|
||||
const loadFileEnvDescriptors = (0, _caching.makeWeakCacheSync)(file => (0, _caching.makeStrongCacheSync)(envName => buildEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, envName)));
|
||||
const loadFileOverridesDescriptors = (0, _caching.makeWeakCacheSync)(file => (0, _caching.makeStrongCacheSync)(index => buildOverrideDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, index)));
|
||||
const loadFileOverridesEnvDescriptors = (0, _caching.makeWeakCacheSync)(file => (0, _caching.makeStrongCacheSync)(index => (0, _caching.makeStrongCacheSync)(envName => buildOverrideEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, index, envName))));
|
||||
|
||||
function buildFileLogger(filepath, context, baseLogger) {
|
||||
if (!baseLogger) {
|
||||
return () => {};
|
||||
}
|
||||
|
||||
return baseLogger.configure(context.showConfig, _printer.ChainFormatter.Config, {
|
||||
filepath
|
||||
});
|
||||
}
|
||||
|
||||
function buildRootDescriptors({
|
||||
dirname,
|
||||
options
|
||||
}, alias, descriptors) {
|
||||
return descriptors(dirname, options, alias);
|
||||
}
|
||||
|
||||
function buildProgrammaticLogger(_, context, baseLogger) {
|
||||
var _context$caller;
|
||||
|
||||
if (!baseLogger) {
|
||||
return () => {};
|
||||
}
|
||||
|
||||
return baseLogger.configure(context.showConfig, _printer.ChainFormatter.Programmatic, {
|
||||
callerName: (_context$caller = context.caller) == null ? void 0 : _context$caller.name
|
||||
});
|
||||
}
|
||||
|
||||
function buildEnvDescriptors({
|
||||
dirname,
|
||||
options
|
||||
@@ -283,7 +236,6 @@ function buildEnvDescriptors({
|
||||
const opts = options.env && options.env[envName];
|
||||
return opts ? descriptors(dirname, opts, `${alias}.env["${envName}"]`) : null;
|
||||
}
|
||||
|
||||
function buildOverrideDescriptors({
|
||||
dirname,
|
||||
options
|
||||
@@ -292,7 +244,6 @@ function buildOverrideDescriptors({
|
||||
if (!opts) throw new Error("Assertion failure - missing override");
|
||||
return descriptors(dirname, opts, `${alias}.overrides[${index}]`);
|
||||
}
|
||||
|
||||
function buildOverrideEnvDescriptors({
|
||||
dirname,
|
||||
options
|
||||
@@ -302,7 +253,6 @@ function buildOverrideEnvDescriptors({
|
||||
const opts = override.env && override.env[envName];
|
||||
return opts ? descriptors(dirname, opts, `${alias}.overrides[${index}].env["${envName}"]`) : null;
|
||||
}
|
||||
|
||||
function makeChainWalker({
|
||||
root,
|
||||
env,
|
||||
@@ -316,7 +266,6 @@ function makeChainWalker({
|
||||
} = input;
|
||||
const flattenedConfigs = [];
|
||||
const rootOpts = root(input);
|
||||
|
||||
if (configIsApplicable(rootOpts, dirname, context, input.filepath)) {
|
||||
flattenedConfigs.push({
|
||||
config: rootOpts,
|
||||
@@ -324,7 +273,6 @@ function makeChainWalker({
|
||||
index: undefined
|
||||
});
|
||||
const envOpts = env(input, context.envName);
|
||||
|
||||
if (envOpts && configIsApplicable(envOpts, dirname, context, input.filepath)) {
|
||||
flattenedConfigs.push({
|
||||
config: envOpts,
|
||||
@@ -332,10 +280,8 @@ function makeChainWalker({
|
||||
index: undefined
|
||||
});
|
||||
}
|
||||
|
||||
(rootOpts.options.overrides || []).forEach((_, index) => {
|
||||
const overrideOps = overrides(input, index);
|
||||
|
||||
if (configIsApplicable(overrideOps, dirname, context, input.filepath)) {
|
||||
flattenedConfigs.push({
|
||||
config: overrideOps,
|
||||
@@ -343,7 +289,6 @@ function makeChainWalker({
|
||||
envName: undefined
|
||||
});
|
||||
const overrideEnvOpts = overridesEnv(input, index, context.envName);
|
||||
|
||||
if (overrideEnvOpts && configIsApplicable(overrideEnvOpts, dirname, context, input.filepath)) {
|
||||
flattenedConfigs.push({
|
||||
config: overrideEnvOpts,
|
||||
@@ -365,10 +310,8 @@ function makeChainWalker({
|
||||
}) => shouldIgnore(context, ignore, only, dirname))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const chain = emptyChain();
|
||||
const logger = createLogger(input, context, baseLogger);
|
||||
|
||||
for (const {
|
||||
config,
|
||||
index,
|
||||
@@ -377,23 +320,18 @@ function makeChainWalker({
|
||||
if (!(yield* mergeExtendsChain(chain, config.options, dirname, context, files, baseLogger))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
logger(config, index, envName);
|
||||
yield* mergeChainOpts(chain, config);
|
||||
}
|
||||
|
||||
return chain;
|
||||
};
|
||||
}
|
||||
|
||||
function* mergeExtendsChain(chain, opts, dirname, context, files, baseLogger) {
|
||||
if (opts.extends === undefined) return true;
|
||||
const file = yield* (0, _files.loadConfig)(opts.extends, dirname, context.envName, context.caller);
|
||||
|
||||
if (files.has(file)) {
|
||||
throw new Error(`Configuration cycle detected loading ${file.filepath}.\n` + `File already loaded following the config chain:\n` + Array.from(files, file => ` - ${file.filepath}`).join("\n"));
|
||||
}
|
||||
|
||||
files.add(file);
|
||||
const fileChain = yield* loadFileChain(validateExtendFile(file), context, files, baseLogger);
|
||||
files.delete(file);
|
||||
@@ -401,19 +339,15 @@ function* mergeExtendsChain(chain, opts, dirname, context, files, baseLogger) {
|
||||
mergeChain(chain, fileChain);
|
||||
return true;
|
||||
}
|
||||
|
||||
function mergeChain(target, source) {
|
||||
target.options.push(...source.options);
|
||||
target.plugins.push(...source.plugins);
|
||||
target.presets.push(...source.presets);
|
||||
|
||||
for (const file of source.files) {
|
||||
target.files.add(file);
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
function* mergeChainOpts(target, {
|
||||
options,
|
||||
plugins,
|
||||
@@ -424,7 +358,6 @@ function* mergeChainOpts(target, {
|
||||
target.presets.push(...(yield* presets()));
|
||||
return target;
|
||||
}
|
||||
|
||||
function emptyChain() {
|
||||
return {
|
||||
options: [],
|
||||
@@ -433,7 +366,6 @@ function emptyChain() {
|
||||
files: new Set()
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeOptions(opts) {
|
||||
const options = Object.assign({}, opts);
|
||||
delete options.extends;
|
||||
@@ -452,31 +384,26 @@ function normalizeOptions(opts) {
|
||||
options.sourceMaps = options.sourceMap;
|
||||
delete options.sourceMap;
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
function dedupDescriptors(items) {
|
||||
const map = new Map();
|
||||
const descriptors = [];
|
||||
|
||||
for (const item of items) {
|
||||
if (typeof item.value === "function") {
|
||||
const fnKey = item.value;
|
||||
let nameMap = map.get(fnKey);
|
||||
|
||||
if (!nameMap) {
|
||||
nameMap = new Map();
|
||||
map.set(fnKey, nameMap);
|
||||
}
|
||||
|
||||
let desc = nameMap.get(item.name);
|
||||
|
||||
if (!desc) {
|
||||
desc = {
|
||||
value: item
|
||||
};
|
||||
descriptors.push(desc);
|
||||
|
||||
if (!item.ownPass) nameMap.set(item.name, desc);
|
||||
} else {
|
||||
desc.value = item;
|
||||
@@ -487,19 +414,16 @@ function dedupDescriptors(items) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return descriptors.reduce((acc, desc) => {
|
||||
acc.push(desc.value);
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
|
||||
function configIsApplicable({
|
||||
options
|
||||
}, dirname, context, configName) {
|
||||
return (options.test === undefined || configFieldIsApplicable(context, options.test, dirname, configName)) && (options.include === undefined || configFieldIsApplicable(context, options.include, dirname, configName)) && (options.exclude === undefined || !configFieldIsApplicable(context, options.exclude, dirname, configName));
|
||||
}
|
||||
|
||||
function configFieldIsApplicable(context, test, dirname, configName) {
|
||||
const patterns = Array.isArray(test) ? test : [test];
|
||||
return matchesPatterns(context, patterns, dirname, configName);
|
||||
@@ -509,44 +433,34 @@ function ignoreListReplacer(_key, value) {
|
||||
if (value instanceof RegExp) {
|
||||
return String(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function shouldIgnore(context, ignore, only, dirname) {
|
||||
if (ignore && matchesPatterns(context, ignore, dirname)) {
|
||||
var _context$filename;
|
||||
|
||||
const message = `No config is applied to "${(_context$filename = context.filename) != null ? _context$filename : "(unknown)"}" because it matches one of \`ignore: ${JSON.stringify(ignore, ignoreListReplacer)}\` from "${dirname}"`;
|
||||
debug(message);
|
||||
|
||||
if (context.showConfig) {
|
||||
console.log(message);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (only && !matchesPatterns(context, only, dirname)) {
|
||||
var _context$filename2;
|
||||
|
||||
const message = `No config is applied to "${(_context$filename2 = context.filename) != null ? _context$filename2 : "(unknown)"}" because it fails to match one of \`only: ${JSON.stringify(only, ignoreListReplacer)}\` from "${dirname}"`;
|
||||
debug(message);
|
||||
|
||||
if (context.showConfig) {
|
||||
console.log(message);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function matchesPatterns(context, patterns, dirname, configName) {
|
||||
return patterns.some(pattern => matchPattern(pattern, dirname, context.filename, context, configName));
|
||||
}
|
||||
|
||||
function matchPattern(pattern, dirname, pathToTest, context, configName) {
|
||||
if (typeof pattern === "function") {
|
||||
return !!(0, _rewriteStackTrace.endHiddenCallStack)(pattern)(pathToTest, {
|
||||
@@ -555,18 +469,14 @@ function matchPattern(pattern, dirname, pathToTest, context, configName) {
|
||||
caller: context.caller
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof pathToTest !== "string") {
|
||||
throw new _configError.default(`Configuration contains string/RegExp pattern, but no filename was passed to Babel`, configName);
|
||||
}
|
||||
|
||||
if (typeof pattern === "string") {
|
||||
pattern = (0, _patternToRegex.default)(pattern, dirname);
|
||||
}
|
||||
|
||||
return pattern.test(pathToTest);
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=config-chain.js.map
|
||||
|
||||
53
tools/node_modules/eslint/node_modules/@babel/core/lib/config/config-descriptors.js
generated
vendored
53
tools/node_modules/eslint/node_modules/@babel/core/lib/config/config-descriptors.js
generated
vendored
@@ -6,40 +6,28 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.createCachedDescriptors = createCachedDescriptors;
|
||||
exports.createDescriptor = createDescriptor;
|
||||
exports.createUncachedDescriptors = createUncachedDescriptors;
|
||||
|
||||
function _gensync() {
|
||||
const data = require("gensync");
|
||||
|
||||
_gensync = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _functional = require("../gensync-utils/functional");
|
||||
|
||||
var _files = require("./files");
|
||||
|
||||
var _item = require("./item");
|
||||
|
||||
var _caching = require("./caching");
|
||||
|
||||
var _resolveTargets = require("./resolve-targets");
|
||||
|
||||
function isEqualDescriptor(a, b) {
|
||||
return a.name === b.name && a.value === b.value && a.options === b.options && a.dirname === b.dirname && a.alias === b.alias && a.ownPass === b.ownPass && (a.file && a.file.request) === (b.file && b.file.request) && (a.file && a.file.resolved) === (b.file && b.file.resolved);
|
||||
}
|
||||
|
||||
function* handlerOf(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
function optionsWithResolvedBrowserslistConfigFile(options, dirname) {
|
||||
if (typeof options.browserslistConfigFile === "string") {
|
||||
options.browserslistConfigFile = (0, _resolveTargets.resolveBrowserslistConfigFile)(options.browserslistConfigFile, dirname);
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -51,8 +39,10 @@ function createCachedDescriptors(dirname, options, alias) {
|
||||
} = options;
|
||||
return {
|
||||
options: optionsWithResolvedBrowserslistConfigFile(options, dirname),
|
||||
plugins: plugins ? () => createCachedPluginDescriptors(plugins, dirname)(alias) : () => handlerOf([]),
|
||||
presets: presets ? () => createCachedPresetDescriptors(presets, dirname)(alias)(!!passPerPreset) : () => handlerOf([])
|
||||
plugins: plugins ? () =>
|
||||
createCachedPluginDescriptors(plugins, dirname)(alias) : () => handlerOf([]),
|
||||
presets: presets ? () =>
|
||||
createCachedPresetDescriptors(presets, dirname)(alias)(!!passPerPreset) : () => handlerOf([])
|
||||
};
|
||||
}
|
||||
|
||||
@@ -63,13 +53,13 @@ function createUncachedDescriptors(dirname, options, alias) {
|
||||
presets: (0, _functional.once)(() => createPresetDescriptors(options.presets || [], dirname, alias, !!options.passPerPreset))
|
||||
};
|
||||
}
|
||||
|
||||
const PRESET_DESCRIPTOR_CACHE = new WeakMap();
|
||||
const createCachedPresetDescriptors = (0, _caching.makeWeakCacheSync)((items, cache) => {
|
||||
const dirname = cache.using(dir => dir);
|
||||
return (0, _caching.makeStrongCacheSync)(alias => (0, _caching.makeStrongCache)(function* (passPerPreset) {
|
||||
const descriptors = yield* createPresetDescriptors(items, dirname, alias, passPerPreset);
|
||||
return descriptors.map(desc => loadCachedDescriptor(PRESET_DESCRIPTOR_CACHE, desc));
|
||||
return descriptors.map(
|
||||
desc => loadCachedDescriptor(PRESET_DESCRIPTOR_CACHE, desc));
|
||||
}));
|
||||
});
|
||||
const PLUGIN_DESCRIPTOR_CACHE = new WeakMap();
|
||||
@@ -77,9 +67,11 @@ const createCachedPluginDescriptors = (0, _caching.makeWeakCacheSync)((items, ca
|
||||
const dirname = cache.using(dir => dir);
|
||||
return (0, _caching.makeStrongCache)(function* (alias) {
|
||||
const descriptors = yield* createPluginDescriptors(items, dirname, alias);
|
||||
return descriptors.map(desc => loadCachedDescriptor(PLUGIN_DESCRIPTOR_CACHE, desc));
|
||||
return descriptors.map(
|
||||
desc => loadCachedDescriptor(PLUGIN_DESCRIPTOR_CACHE, desc));
|
||||
});
|
||||
});
|
||||
|
||||
const DEFAULT_OPTIONS = {};
|
||||
|
||||
function loadCachedDescriptor(cache, desc) {
|
||||
@@ -89,40 +81,30 @@ function loadCachedDescriptor(cache, desc) {
|
||||
} = desc;
|
||||
if (options === false) return desc;
|
||||
let cacheByOptions = cache.get(value);
|
||||
|
||||
if (!cacheByOptions) {
|
||||
cacheByOptions = new WeakMap();
|
||||
cache.set(value, cacheByOptions);
|
||||
}
|
||||
|
||||
let possibilities = cacheByOptions.get(options);
|
||||
|
||||
if (!possibilities) {
|
||||
possibilities = [];
|
||||
cacheByOptions.set(options, possibilities);
|
||||
}
|
||||
|
||||
if (possibilities.indexOf(desc) === -1) {
|
||||
const matches = possibilities.filter(possibility => isEqualDescriptor(possibility, desc));
|
||||
|
||||
if (matches.length > 0) {
|
||||
return matches[0];
|
||||
}
|
||||
|
||||
possibilities.push(desc);
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
function* createPresetDescriptors(items, dirname, alias, passPerPreset) {
|
||||
return yield* createDescriptors("preset", items, dirname, alias, passPerPreset);
|
||||
}
|
||||
|
||||
function* createPluginDescriptors(items, dirname, alias) {
|
||||
return yield* createDescriptors("plugin", items, dirname, alias);
|
||||
}
|
||||
|
||||
function* createDescriptors(type, items, dirname, alias, ownPass) {
|
||||
const descriptors = yield* _gensync().all(items.map((item, index) => createDescriptor(item, dirname, {
|
||||
type,
|
||||
@@ -139,15 +121,12 @@ function* createDescriptor(pair, dirname, {
|
||||
ownPass
|
||||
}) {
|
||||
const desc = (0, _item.getItemDescriptor)(pair);
|
||||
|
||||
if (desc) {
|
||||
return desc;
|
||||
}
|
||||
|
||||
let name;
|
||||
let options;
|
||||
let value = pair;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
if (value.length === 3) {
|
||||
[value, options, name] = value;
|
||||
@@ -155,15 +134,12 @@ function* createDescriptor(pair, dirname, {
|
||||
[value, options] = value;
|
||||
}
|
||||
}
|
||||
|
||||
let file = undefined;
|
||||
let filepath = null;
|
||||
|
||||
if (typeof value === "string") {
|
||||
if (typeof type !== "string") {
|
||||
throw new Error("To resolve a string-based item, the type of item must be given");
|
||||
}
|
||||
|
||||
const resolver = type === "plugin" ? _files.loadPlugin : _files.loadPreset;
|
||||
const request = value;
|
||||
({
|
||||
@@ -175,11 +151,9 @@ function* createDescriptor(pair, dirname, {
|
||||
resolved: filepath
|
||||
};
|
||||
}
|
||||
|
||||
if (!value) {
|
||||
throw new Error(`Unexpected falsy value: ${String(value)}`);
|
||||
}
|
||||
|
||||
if (typeof value === "object" && value.__esModule) {
|
||||
if (value.default) {
|
||||
value = value.default;
|
||||
@@ -187,15 +161,12 @@ function* createDescriptor(pair, dirname, {
|
||||
throw new Error("Must export a default export when using ES6 modules.");
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof value !== "object" && typeof value !== "function") {
|
||||
throw new Error(`Unsupported format: ${typeof value}. Expected an object or a function.`);
|
||||
}
|
||||
|
||||
if (filepath !== null && typeof value === "object" && value) {
|
||||
throw new Error(`Plugin/Preset files are not allowed to export objects, only functions. In ${filepath}`);
|
||||
}
|
||||
|
||||
return {
|
||||
name,
|
||||
alias: filepath || alias,
|
||||
@@ -206,28 +177,22 @@ function* createDescriptor(pair, dirname, {
|
||||
file
|
||||
};
|
||||
}
|
||||
|
||||
function assertNoDuplicates(items) {
|
||||
const map = new Map();
|
||||
|
||||
for (const item of items) {
|
||||
if (typeof item.value !== "function") continue;
|
||||
let nameMap = map.get(item.value);
|
||||
|
||||
if (!nameMap) {
|
||||
nameMap = new Set();
|
||||
map.set(item.value, nameMap);
|
||||
}
|
||||
|
||||
if (nameMap.has(item.name)) {
|
||||
const conflicts = items.filter(i => i.value === item.value);
|
||||
throw new Error([`Duplicate plugin/preset detected.`, `If you'd like to use two separate instances of a plugin,`, `they need separate names, e.g.`, ``, ` plugins: [`, ` ['some-plugin', {}],`, ` ['some-plugin', {}, 'some unique name'],`, ` ]`, ``, `Duplicates detected are:`, `${JSON.stringify(conflicts, null, 2)}`].join("\n"));
|
||||
}
|
||||
|
||||
nameMap.add(item.name);
|
||||
}
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=config-descriptors.js.map
|
||||
|
||||
232
tools/node_modules/eslint/node_modules/@babel/core/lib/config/files/configuration.js
generated
vendored
232
tools/node_modules/eslint/node_modules/@babel/core/lib/config/files/configuration.js
generated
vendored
@@ -9,192 +9,61 @@ exports.findRelativeConfig = findRelativeConfig;
|
||||
exports.findRootConfig = findRootConfig;
|
||||
exports.loadConfig = loadConfig;
|
||||
exports.resolveShowConfigPath = resolveShowConfigPath;
|
||||
|
||||
function _debug() {
|
||||
const data = require("debug");
|
||||
|
||||
_debug = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _fs() {
|
||||
const data = require("fs");
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _json() {
|
||||
const data = require("json5");
|
||||
|
||||
_json = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _gensync() {
|
||||
const data = require("gensync");
|
||||
|
||||
_gensync = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _caching = require("../caching");
|
||||
|
||||
var _configApi = require("../helpers/config-api");
|
||||
|
||||
var _utils = require("./utils");
|
||||
|
||||
var _moduleTypes = require("./module-types");
|
||||
|
||||
var _patternToRegex = require("../pattern-to-regex");
|
||||
|
||||
var _configError = require("../../errors/config-error");
|
||||
|
||||
var fs = require("../../gensync-utils/fs");
|
||||
|
||||
function _module() {
|
||||
const data = require("module");
|
||||
|
||||
_module = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _rewriteStackTrace = require("../../errors/rewrite-stack-trace");
|
||||
|
||||
const debug = _debug()("babel:config:loading:files:configuration");
|
||||
|
||||
const ROOT_CONFIG_FILENAMES = ["babel.config.js", "babel.config.cjs", "babel.config.mjs", "babel.config.json"];
|
||||
exports.ROOT_CONFIG_FILENAMES = ROOT_CONFIG_FILENAMES;
|
||||
const RELATIVE_CONFIG_FILENAMES = [".babelrc", ".babelrc.js", ".babelrc.cjs", ".babelrc.mjs", ".babelrc.json"];
|
||||
const BABELIGNORE_FILENAME = ".babelignore";
|
||||
|
||||
function findConfigUpwards(rootDir) {
|
||||
let dirname = rootDir;
|
||||
|
||||
for (;;) {
|
||||
for (const filename of ROOT_CONFIG_FILENAMES) {
|
||||
if (_fs().existsSync(_path().join(dirname, filename))) {
|
||||
return dirname;
|
||||
}
|
||||
}
|
||||
|
||||
const nextDir = _path().dirname(dirname);
|
||||
|
||||
if (dirname === nextDir) break;
|
||||
dirname = nextDir;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function* findRelativeConfig(packageData, envName, caller) {
|
||||
let config = null;
|
||||
let ignore = null;
|
||||
|
||||
const dirname = _path().dirname(packageData.filepath);
|
||||
|
||||
for (const loc of packageData.directories) {
|
||||
if (!config) {
|
||||
var _packageData$pkg;
|
||||
|
||||
config = yield* loadOneConfig(RELATIVE_CONFIG_FILENAMES, loc, envName, caller, ((_packageData$pkg = packageData.pkg) == null ? void 0 : _packageData$pkg.dirname) === loc ? packageToBabelConfig(packageData.pkg) : null);
|
||||
}
|
||||
|
||||
if (!ignore) {
|
||||
const ignoreLoc = _path().join(loc, BABELIGNORE_FILENAME);
|
||||
|
||||
ignore = yield* readIgnoreConfig(ignoreLoc);
|
||||
|
||||
if (ignore) {
|
||||
debug("Found ignore %o from %o.", ignore.filepath, dirname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
config,
|
||||
ignore
|
||||
};
|
||||
}
|
||||
|
||||
function findRootConfig(dirname, envName, caller) {
|
||||
return loadOneConfig(ROOT_CONFIG_FILENAMES, dirname, envName, caller);
|
||||
}
|
||||
|
||||
function* loadOneConfig(names, dirname, envName, caller, previousConfig = null) {
|
||||
const configs = yield* _gensync().all(names.map(filename => readConfig(_path().join(dirname, filename), envName, caller)));
|
||||
const config = configs.reduce((previousConfig, config) => {
|
||||
if (config && previousConfig) {
|
||||
throw new _configError.default(`Multiple configuration files found. Please remove one:\n` + ` - ${_path().basename(previousConfig.filepath)}\n` + ` - ${config.filepath}\n` + `from ${dirname}`);
|
||||
}
|
||||
|
||||
return config || previousConfig;
|
||||
}, previousConfig);
|
||||
|
||||
if (config) {
|
||||
debug("Found configuration %o from %o.", config.filepath, dirname);
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
function* loadConfig(name, dirname, envName, caller) {
|
||||
const filepath = (((v, w) => (v = v.split("."), w = w.split("."), +v[0] > +w[0] || v[0] == w[0] && +v[1] >= +w[1]))(process.versions.node, "8.9") ? require.resolve : (r, {
|
||||
paths: [b]
|
||||
}, M = require("module")) => {
|
||||
let f = M._findPath(r, M._nodeModulePaths(b).concat(b));
|
||||
|
||||
if (f) return f;
|
||||
f = new Error(`Cannot resolve module '${r}'`);
|
||||
f.code = "MODULE_NOT_FOUND";
|
||||
throw f;
|
||||
})(name, {
|
||||
paths: [dirname]
|
||||
});
|
||||
const conf = yield* readConfig(filepath, envName, caller);
|
||||
|
||||
if (!conf) {
|
||||
throw new _configError.default(`Config file contains no configuration data`, filepath);
|
||||
}
|
||||
|
||||
debug("Loaded config %o from %o.", name, dirname);
|
||||
return conf;
|
||||
}
|
||||
|
||||
function readConfig(filepath, envName, caller) {
|
||||
const ext = _path().extname(filepath);
|
||||
|
||||
return ext === ".js" || ext === ".cjs" || ext === ".mjs" ? readConfigJS(filepath, {
|
||||
envName,
|
||||
caller
|
||||
}) : readConfigJSON5(filepath);
|
||||
}
|
||||
|
||||
const LOADING_CONFIGS = new Set();
|
||||
const readConfigJS = (0, _caching.makeStrongCache)(function* readConfigJS(filepath, cache) {
|
||||
if (!_fs().existsSync(filepath)) {
|
||||
@@ -211,24 +80,19 @@ const readConfigJS = (0, _caching.makeStrongCache)(function* readConfigJS(filepa
|
||||
options: {}
|
||||
};
|
||||
}
|
||||
|
||||
let options;
|
||||
|
||||
try {
|
||||
LOADING_CONFIGS.add(filepath);
|
||||
options = yield* (0, _moduleTypes.default)(filepath, "You appear to be using a native ECMAScript module configuration " + "file, which is only supported when running Babel asynchronously.");
|
||||
} finally {
|
||||
LOADING_CONFIGS.delete(filepath);
|
||||
}
|
||||
|
||||
let assertCache = false;
|
||||
|
||||
if (typeof options === "function") {
|
||||
yield* [];
|
||||
options = (0, _rewriteStackTrace.endHiddenCallStack)(options)((0, _configApi.makeConfigAPI)(cache));
|
||||
assertCache = true;
|
||||
}
|
||||
|
||||
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
||||
throw new _configError.default(`Configuration should be an exported JavaScript object.`, filepath);
|
||||
}
|
||||
@@ -236,7 +100,6 @@ const readConfigJS = (0, _caching.makeStrongCache)(function* readConfigJS(filepa
|
||||
if (typeof options.then === "function") {
|
||||
throw new _configError.default(`You appear to be using an async configuration, ` + `which your current version of Babel does not support. ` + `We may add support for this in the future, ` + `but if you're on the most recent version of @babel/core and still ` + `seeing this error, then you'll need to synchronously return your config.`, filepath);
|
||||
}
|
||||
|
||||
if (assertCache && !cache.configured()) throwConfigError(filepath);
|
||||
return {
|
||||
filepath,
|
||||
@@ -247,11 +110,9 @@ const readConfigJS = (0, _caching.makeStrongCache)(function* readConfigJS(filepa
|
||||
const packageToBabelConfig = (0, _caching.makeWeakCacheSync)(file => {
|
||||
const babel = file.options["babel"];
|
||||
if (typeof babel === "undefined") return null;
|
||||
|
||||
if (typeof babel !== "object" || Array.isArray(babel) || babel === null) {
|
||||
throw new _configError.default(`.babel property must be an object`, file.filepath);
|
||||
}
|
||||
|
||||
return {
|
||||
filepath: file.filepath,
|
||||
dirname: file.dirname,
|
||||
@@ -260,23 +121,18 @@ const packageToBabelConfig = (0, _caching.makeWeakCacheSync)(file => {
|
||||
});
|
||||
const readConfigJSON5 = (0, _utils.makeStaticFileCache)((filepath, content) => {
|
||||
let options;
|
||||
|
||||
try {
|
||||
options = _json().parse(content);
|
||||
} catch (err) {
|
||||
throw new _configError.default(`Error while parsing config - ${err.message}`, filepath);
|
||||
}
|
||||
|
||||
if (!options) throw new _configError.default(`No config detected`, filepath);
|
||||
|
||||
if (typeof options !== "object") {
|
||||
throw new _configError.default(`Config returned typeof ${typeof options}`, filepath);
|
||||
}
|
||||
|
||||
if (Array.isArray(options)) {
|
||||
throw new _configError.default(`Expected config object but found array`, filepath);
|
||||
}
|
||||
|
||||
delete options["$schema"];
|
||||
return {
|
||||
filepath,
|
||||
@@ -286,40 +142,109 @@ const readConfigJSON5 = (0, _utils.makeStaticFileCache)((filepath, content) => {
|
||||
});
|
||||
const readIgnoreConfig = (0, _utils.makeStaticFileCache)((filepath, content) => {
|
||||
const ignoreDir = _path().dirname(filepath);
|
||||
|
||||
const ignorePatterns = content.split("\n").map(line => line.replace(/#(.*?)$/, "").trim()).filter(line => !!line);
|
||||
|
||||
for (const pattern of ignorePatterns) {
|
||||
if (pattern[0] === "!") {
|
||||
throw new _configError.default(`Negation of file paths is not supported.`, filepath);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
filepath,
|
||||
dirname: _path().dirname(filepath),
|
||||
ignore: ignorePatterns.map(pattern => (0, _patternToRegex.default)(pattern, ignoreDir))
|
||||
};
|
||||
});
|
||||
function findConfigUpwards(rootDir) {
|
||||
let dirname = rootDir;
|
||||
for (;;) {
|
||||
for (const filename of ROOT_CONFIG_FILENAMES) {
|
||||
if (_fs().existsSync(_path().join(dirname, filename))) {
|
||||
return dirname;
|
||||
}
|
||||
}
|
||||
const nextDir = _path().dirname(dirname);
|
||||
if (dirname === nextDir) break;
|
||||
dirname = nextDir;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function* findRelativeConfig(packageData, envName, caller) {
|
||||
let config = null;
|
||||
let ignore = null;
|
||||
const dirname = _path().dirname(packageData.filepath);
|
||||
for (const loc of packageData.directories) {
|
||||
if (!config) {
|
||||
var _packageData$pkg;
|
||||
config = yield* loadOneConfig(RELATIVE_CONFIG_FILENAMES, loc, envName, caller, ((_packageData$pkg = packageData.pkg) == null ? void 0 : _packageData$pkg.dirname) === loc ? packageToBabelConfig(packageData.pkg) : null);
|
||||
}
|
||||
if (!ignore) {
|
||||
const ignoreLoc = _path().join(loc, BABELIGNORE_FILENAME);
|
||||
ignore = yield* readIgnoreConfig(ignoreLoc);
|
||||
if (ignore) {
|
||||
debug("Found ignore %o from %o.", ignore.filepath, dirname);
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
config,
|
||||
ignore
|
||||
};
|
||||
}
|
||||
function findRootConfig(dirname, envName, caller) {
|
||||
return loadOneConfig(ROOT_CONFIG_FILENAMES, dirname, envName, caller);
|
||||
}
|
||||
function* loadOneConfig(names, dirname, envName, caller, previousConfig = null) {
|
||||
const configs = yield* _gensync().all(names.map(filename => readConfig(_path().join(dirname, filename), envName, caller)));
|
||||
const config = configs.reduce((previousConfig, config) => {
|
||||
if (config && previousConfig) {
|
||||
throw new _configError.default(`Multiple configuration files found. Please remove one:\n` + ` - ${_path().basename(previousConfig.filepath)}\n` + ` - ${config.filepath}\n` + `from ${dirname}`);
|
||||
}
|
||||
return config || previousConfig;
|
||||
}, previousConfig);
|
||||
if (config) {
|
||||
debug("Found configuration %o from %o.", config.filepath, dirname);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
function* loadConfig(name, dirname, envName, caller) {
|
||||
const filepath = (((v, w) => (v = v.split("."), w = w.split("."), +v[0] > +w[0] || v[0] == w[0] && +v[1] >= +w[1]))(process.versions.node, "8.9") ? require.resolve : (r, {
|
||||
paths: [b]
|
||||
}, M = require("module")) => {
|
||||
let f = M._findPath(r, M._nodeModulePaths(b).concat(b));
|
||||
if (f) return f;
|
||||
f = new Error(`Cannot resolve module '${r}'`);
|
||||
f.code = "MODULE_NOT_FOUND";
|
||||
throw f;
|
||||
})(name, {
|
||||
paths: [dirname]
|
||||
});
|
||||
const conf = yield* readConfig(filepath, envName, caller);
|
||||
if (!conf) {
|
||||
throw new _configError.default(`Config file contains no configuration data`, filepath);
|
||||
}
|
||||
debug("Loaded config %o from %o.", name, dirname);
|
||||
return conf;
|
||||
}
|
||||
|
||||
function readConfig(filepath, envName, caller) {
|
||||
const ext = _path().extname(filepath);
|
||||
return ext === ".js" || ext === ".cjs" || ext === ".mjs" ? readConfigJS(filepath, {
|
||||
envName,
|
||||
caller
|
||||
}) : readConfigJSON5(filepath);
|
||||
}
|
||||
function* resolveShowConfigPath(dirname) {
|
||||
const targetPath = process.env.BABEL_SHOW_CONFIG_FOR;
|
||||
|
||||
if (targetPath != null) {
|
||||
const absolutePath = _path().resolve(dirname, targetPath);
|
||||
|
||||
const stats = yield* fs.stat(absolutePath);
|
||||
|
||||
if (!stats.isFile()) {
|
||||
throw new Error(`${absolutePath}: BABEL_SHOW_CONFIG_FOR must refer to a regular file, directories are not supported.`);
|
||||
}
|
||||
|
||||
return absolutePath;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function throwConfigError(filepath) {
|
||||
throw new _configError.default(`\
|
||||
Caching was left unconfigured. Babel's plugins, presets, and .babelrc.js files can be configured
|
||||
@@ -356,7 +281,6 @@ module.exports = function(api) {
|
||||
return { };
|
||||
};`, filepath);
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=configuration.js.map
|
||||
|
||||
@@ -4,42 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = resolve;
|
||||
|
||||
function _module() {
|
||||
const data = require("module");
|
||||
|
||||
_module = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _importMetaResolve = require("../../vendor/import-meta-resolve");
|
||||
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
||||
|
||||
let import_;
|
||||
|
||||
try {
|
||||
import_ = require("./import.cjs");
|
||||
} catch (_unused) {}
|
||||
|
||||
const importMetaResolveP = import_ && process.execArgv.includes("--experimental-import-meta-resolve") ? import_("data:text/javascript,export default import.meta.resolve").then(m => m.default || _importMetaResolve.resolve, () => _importMetaResolve.resolve) : Promise.resolve(_importMetaResolve.resolve);
|
||||
|
||||
const importMetaResolveP = import_ &&
|
||||
process.execArgv.includes("--experimental-import-meta-resolve") ? import_("data:text/javascript,export default import.meta.resolve").then(m => m.default || _importMetaResolve.resolve, () => _importMetaResolve.resolve) : Promise.resolve(_importMetaResolve.resolve);
|
||||
function resolve(_x, _x2) {
|
||||
return _resolve.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _resolve() {
|
||||
_resolve = _asyncToGenerator(function* (specifier, parent) {
|
||||
return (yield importMetaResolveP)(specifier, parent);
|
||||
});
|
||||
return _resolve.apply(this, arguments);
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=import-meta-resolve.js.map
|
||||
|
||||
3
tools/node_modules/eslint/node_modules/@babel/core/lib/config/files/import.cjs
generated
vendored
3
tools/node_modules/eslint/node_modules/@babel/core/lib/config/files/import.cjs
generated
vendored
@@ -1,7 +1,8 @@
|
||||
|
||||
|
||||
module.exports = function import_(filepath) {
|
||||
return import(filepath);
|
||||
};
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=import.cjs.map
|
||||
|
||||
27
tools/node_modules/eslint/node_modules/@babel/core/lib/config/files/index-browser.js
generated
vendored
27
tools/node_modules/eslint/node_modules/@babel/core/lib/config/files/index-browser.js
generated
vendored
@@ -14,8 +14,8 @@ exports.loadPreset = loadPreset;
|
||||
exports.resolvePlugin = resolvePlugin;
|
||||
exports.resolvePreset = resolvePreset;
|
||||
exports.resolveShowConfigPath = resolveShowConfigPath;
|
||||
|
||||
function findConfigUpwards(rootDir) {
|
||||
function findConfigUpwards(
|
||||
rootDir) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -28,28 +28,36 @@ function* findPackageData(filepath) {
|
||||
};
|
||||
}
|
||||
|
||||
function* findRelativeConfig(pkgData, envName, caller) {
|
||||
function* findRelativeConfig(
|
||||
pkgData,
|
||||
envName,
|
||||
caller) {
|
||||
return {
|
||||
config: null,
|
||||
ignore: null
|
||||
};
|
||||
}
|
||||
|
||||
function* findRootConfig(dirname, envName, caller) {
|
||||
function* findRootConfig(
|
||||
dirname,
|
||||
envName,
|
||||
caller) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function* loadConfig(name, dirname, envName, caller) {
|
||||
function* loadConfig(name, dirname,
|
||||
envName,
|
||||
caller) {
|
||||
throw new Error(`Cannot load ${name} relative to ${dirname} in a browser`);
|
||||
}
|
||||
|
||||
function* resolveShowConfigPath(dirname) {
|
||||
function* resolveShowConfigPath(
|
||||
dirname) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const ROOT_CONFIG_FILENAMES = [];
|
||||
exports.ROOT_CONFIG_FILENAMES = ROOT_CONFIG_FILENAMES;
|
||||
|
||||
exports.ROOT_CONFIG_FILENAMES = ROOT_CONFIG_FILENAMES;
|
||||
function resolvePlugin(name, dirname) {
|
||||
return null;
|
||||
}
|
||||
@@ -57,15 +65,12 @@ function resolvePlugin(name, dirname) {
|
||||
function resolvePreset(name, dirname) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function loadPlugin(name, dirname) {
|
||||
throw new Error(`Cannot load plugin ${name} relative to ${dirname} in a browser`);
|
||||
}
|
||||
|
||||
function loadPreset(name, dirname) {
|
||||
throw new Error(`Cannot load preset ${name} relative to ${dirname} in a browser`);
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=index-browser.js.map
|
||||
|
||||
11
tools/node_modules/eslint/node_modules/@babel/core/lib/config/files/index.js
generated
vendored
11
tools/node_modules/eslint/node_modules/@babel/core/lib/config/files/index.js
generated
vendored
@@ -58,31 +58,20 @@ Object.defineProperty(exports, "resolveShowConfigPath", {
|
||||
return _configuration.resolveShowConfigPath;
|
||||
}
|
||||
});
|
||||
|
||||
var _package = require("./package");
|
||||
|
||||
var _configuration = require("./configuration");
|
||||
|
||||
var plugins = require("./plugins");
|
||||
|
||||
function _gensync() {
|
||||
const data = require("gensync");
|
||||
|
||||
_gensync = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
({});
|
||||
|
||||
const resolvePlugin = _gensync()(plugins.resolvePlugin).sync;
|
||||
|
||||
exports.resolvePlugin = resolvePlugin;
|
||||
|
||||
const resolvePreset = _gensync()(plugins.resolvePreset).sync;
|
||||
|
||||
exports.resolvePreset = resolvePreset;
|
||||
0 && 0;
|
||||
|
||||
|
||||
41
tools/node_modules/eslint/node_modules/@babel/core/lib/config/files/module-types.js
generated
vendored
41
tools/node_modules/eslint/node_modules/@babel/core/lib/config/files/module-types.js
generated
vendored
@@ -5,110 +5,82 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
exports.default = loadCjsOrMjsDefault;
|
||||
exports.supportsESM = void 0;
|
||||
|
||||
var _async = require("../../gensync-utils/async");
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _url() {
|
||||
const data = require("url");
|
||||
|
||||
_url = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _module() {
|
||||
const data = require("module");
|
||||
|
||||
_module = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _semver() {
|
||||
const data = require("semver");
|
||||
|
||||
_semver = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _rewriteStackTrace = require("../../errors/rewrite-stack-trace");
|
||||
|
||||
var _configError = require("../../errors/config-error");
|
||||
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
||||
|
||||
let import_;
|
||||
|
||||
try {
|
||||
import_ = require("./import.cjs");
|
||||
} catch (_unused) {}
|
||||
|
||||
const supportsESM = _semver().satisfies(process.versions.node, "^12.17 || >=13.2");
|
||||
|
||||
const supportsESM = _semver().satisfies(process.versions.node,
|
||||
"^12.17 || >=13.2");
|
||||
exports.supportsESM = supportsESM;
|
||||
|
||||
function* loadCjsOrMjsDefault(filepath, asyncError, fallbackToTranspiledModule = false) {
|
||||
function* loadCjsOrMjsDefault(filepath, asyncError,
|
||||
fallbackToTranspiledModule = false) {
|
||||
switch (guessJSModuleType(filepath)) {
|
||||
case "cjs":
|
||||
return loadCjsDefault(filepath, fallbackToTranspiledModule);
|
||||
|
||||
case "unknown":
|
||||
try {
|
||||
return loadCjsDefault(filepath, fallbackToTranspiledModule);
|
||||
} catch (e) {
|
||||
if (e.code !== "ERR_REQUIRE_ESM") throw e;
|
||||
}
|
||||
|
||||
case "mjs":
|
||||
if (yield* (0, _async.isAsync)()) {
|
||||
return yield* (0, _async.waitFor)(loadMjsDefault(filepath));
|
||||
}
|
||||
|
||||
throw new _configError.default(asyncError, filepath);
|
||||
}
|
||||
}
|
||||
|
||||
function guessJSModuleType(filename) {
|
||||
switch (_path().extname(filename)) {
|
||||
case ".cjs":
|
||||
return "cjs";
|
||||
|
||||
case ".mjs":
|
||||
return "mjs";
|
||||
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
function loadCjsDefault(filepath, fallbackToTranspiledModule) {
|
||||
const module = (0, _rewriteStackTrace.endHiddenCallStack)(require)(filepath);
|
||||
return module != null && module.__esModule ? module.default || (fallbackToTranspiledModule ? module : undefined) : module;
|
||||
return module != null && module.__esModule ?
|
||||
module.default || (fallbackToTranspiledModule ? module : undefined) : module;
|
||||
}
|
||||
|
||||
function loadMjsDefault(_x) {
|
||||
return _loadMjsDefault.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _loadMjsDefault() {
|
||||
_loadMjsDefault = _asyncToGenerator(function* (filepath) {
|
||||
if (!import_) {
|
||||
@@ -120,7 +92,6 @@ function _loadMjsDefault() {
|
||||
});
|
||||
return _loadMjsDefault.apply(this, arguments);
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=module-types.js.map
|
||||
|
||||
58
tools/node_modules/eslint/node_modules/@babel/core/lib/config/files/package.js
generated
vendored
58
tools/node_modules/eslint/node_modules/@babel/core/lib/config/files/package.js
generated
vendored
@@ -4,44 +4,52 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.findPackageData = findPackageData;
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _utils = require("./utils");
|
||||
|
||||
var _configError = require("../../errors/config-error");
|
||||
|
||||
const PACKAGE_FILENAME = "package.json";
|
||||
const readConfigPackage = (0, _utils.makeStaticFileCache)((filepath, content) => {
|
||||
let options;
|
||||
try {
|
||||
options = JSON.parse(content);
|
||||
} catch (err) {
|
||||
throw new _configError.default(`Error while parsing JSON - ${err.message}`, filepath);
|
||||
}
|
||||
if (!options) throw new Error(`${filepath}: No config detected`);
|
||||
if (typeof options !== "object") {
|
||||
throw new _configError.default(`Config returned typeof ${typeof options}`, filepath);
|
||||
}
|
||||
if (Array.isArray(options)) {
|
||||
throw new _configError.default(`Expected config object but found array`, filepath);
|
||||
}
|
||||
return {
|
||||
filepath,
|
||||
dirname: _path().dirname(filepath),
|
||||
options
|
||||
};
|
||||
});
|
||||
|
||||
function* findPackageData(filepath) {
|
||||
let pkg = null;
|
||||
const directories = [];
|
||||
let isPackage = true;
|
||||
|
||||
let dirname = _path().dirname(filepath);
|
||||
|
||||
while (!pkg && _path().basename(dirname) !== "node_modules") {
|
||||
directories.push(dirname);
|
||||
pkg = yield* readConfigPackage(_path().join(dirname, PACKAGE_FILENAME));
|
||||
|
||||
const nextLoc = _path().dirname(dirname);
|
||||
|
||||
if (dirname === nextLoc) {
|
||||
isPackage = false;
|
||||
break;
|
||||
}
|
||||
|
||||
dirname = nextLoc;
|
||||
}
|
||||
|
||||
return {
|
||||
filepath,
|
||||
directories,
|
||||
@@ -49,32 +57,6 @@ function* findPackageData(filepath) {
|
||||
isPackage
|
||||
};
|
||||
}
|
||||
|
||||
const readConfigPackage = (0, _utils.makeStaticFileCache)((filepath, content) => {
|
||||
let options;
|
||||
|
||||
try {
|
||||
options = JSON.parse(content);
|
||||
} catch (err) {
|
||||
throw new _configError.default(`Error while parsing JSON - ${err.message}`, filepath);
|
||||
}
|
||||
|
||||
if (!options) throw new Error(`${filepath}: No config detected`);
|
||||
|
||||
if (typeof options !== "object") {
|
||||
throw new _configError.default(`Config returned typeof ${typeof options}`, filepath);
|
||||
}
|
||||
|
||||
if (Array.isArray(options)) {
|
||||
throw new _configError.default(`Expected config object but found array`, filepath);
|
||||
}
|
||||
|
||||
return {
|
||||
filepath,
|
||||
dirname: _path().dirname(filepath),
|
||||
options
|
||||
};
|
||||
});
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=package.js.map
|
||||
|
||||
63
tools/node_modules/eslint/node_modules/@babel/core/lib/config/files/plugins.js
generated
vendored
63
tools/node_modules/eslint/node_modules/@babel/core/lib/config/files/plugins.js
generated
vendored
@@ -7,69 +7,47 @@ exports.loadPlugin = loadPlugin;
|
||||
exports.loadPreset = loadPreset;
|
||||
exports.resolvePlugin = resolvePlugin;
|
||||
exports.resolvePreset = resolvePreset;
|
||||
|
||||
function _debug() {
|
||||
const data = require("debug");
|
||||
|
||||
_debug = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _gensync() {
|
||||
const data = require("gensync");
|
||||
|
||||
_gensync = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _async = require("../../gensync-utils/async");
|
||||
|
||||
var _moduleTypes = require("./module-types");
|
||||
|
||||
function _url() {
|
||||
const data = require("url");
|
||||
|
||||
_url = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _importMetaResolve = require("./import-meta-resolve");
|
||||
|
||||
function _module() {
|
||||
const data = require("module");
|
||||
|
||||
_module = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
||||
|
||||
const debug = _debug()("babel:config:loading:files:plugins");
|
||||
|
||||
const EXACT_RE = /^module:/;
|
||||
const BABEL_PLUGIN_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-plugin-)/;
|
||||
const BABEL_PRESET_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-preset-)/;
|
||||
@@ -78,15 +56,12 @@ const BABEL_PRESET_ORG_RE = /^(@babel\/)(?!preset-|[^/]+\/)/;
|
||||
const OTHER_PLUGIN_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-plugin(?:-|\/|$)|[^/]+\/)/;
|
||||
const OTHER_PRESET_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-preset(?:-|\/|$)|[^/]+\/)/;
|
||||
const OTHER_ORG_DEFAULT_RE = /^(@(?!babel$)[^/]+)$/;
|
||||
|
||||
function* resolvePlugin(name, dirname) {
|
||||
return yield* resolveStandardizedName("plugin", name, dirname);
|
||||
}
|
||||
|
||||
function* resolvePreset(name, dirname) {
|
||||
return yield* resolveStandardizedName("preset", name, dirname);
|
||||
}
|
||||
|
||||
function* loadPlugin(name, dirname) {
|
||||
const filepath = yield* resolvePlugin(name, dirname);
|
||||
const value = yield* requireModule("plugin", filepath);
|
||||
@@ -96,7 +71,6 @@ function* loadPlugin(name, dirname) {
|
||||
value
|
||||
};
|
||||
}
|
||||
|
||||
function* loadPreset(name, dirname) {
|
||||
const filepath = yield* resolvePreset(name, dirname);
|
||||
const value = yield* requireModule("preset", filepath);
|
||||
@@ -106,13 +80,16 @@ function* loadPreset(name, dirname) {
|
||||
value
|
||||
};
|
||||
}
|
||||
|
||||
function standardizeName(type, name) {
|
||||
if (_path().isAbsolute(name)) return name;
|
||||
const isPreset = type === "preset";
|
||||
return name.replace(isPreset ? BABEL_PRESET_PREFIX_RE : BABEL_PLUGIN_PREFIX_RE, `babel-${type}-`).replace(isPreset ? BABEL_PRESET_ORG_RE : BABEL_PLUGIN_ORG_RE, `$1${type}-`).replace(isPreset ? OTHER_PRESET_ORG_RE : OTHER_PLUGIN_ORG_RE, `$1babel-${type}-`).replace(OTHER_ORG_DEFAULT_RE, `$1/babel-${type}`).replace(EXACT_RE, "");
|
||||
return name
|
||||
.replace(isPreset ? BABEL_PRESET_PREFIX_RE : BABEL_PLUGIN_PREFIX_RE, `babel-${type}-`)
|
||||
.replace(isPreset ? BABEL_PRESET_ORG_RE : BABEL_PLUGIN_ORG_RE, `$1${type}-`)
|
||||
.replace(isPreset ? OTHER_PRESET_ORG_RE : OTHER_PLUGIN_ORG_RE, `$1babel-${type}-`)
|
||||
.replace(OTHER_ORG_DEFAULT_RE, `$1/babel-${type}`)
|
||||
.replace(EXACT_RE, "");
|
||||
}
|
||||
|
||||
function* resolveAlternativesHelper(type, name) {
|
||||
const standardizedName = standardizeName(type, name);
|
||||
const {
|
||||
@@ -120,25 +97,20 @@ function* resolveAlternativesHelper(type, name) {
|
||||
value
|
||||
} = yield standardizedName;
|
||||
if (!error) return value;
|
||||
if (error.code !== "MODULE_NOT_FOUND") throw error;
|
||||
|
||||
if (error.code !== "MODULE_NOT_FOUND") throw error;
|
||||
if (standardizedName !== name && !(yield name).error) {
|
||||
error.message += `\n- If you want to resolve "${name}", use "module:${name}"`;
|
||||
}
|
||||
|
||||
if (!(yield standardizeName(type, "@babel/" + name)).error) {
|
||||
error.message += `\n- Did you mean "@babel/${name}"?`;
|
||||
}
|
||||
|
||||
const oppositeType = type === "preset" ? "plugin" : "preset";
|
||||
|
||||
if (!(yield standardizeName(oppositeType, name)).error) {
|
||||
error.message += `\n- Did you accidentally pass a ${oppositeType} as a ${type}?`;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
function tryRequireResolve(id, {
|
||||
paths: [dirname]
|
||||
}) {
|
||||
@@ -149,7 +121,6 @@ function tryRequireResolve(id, {
|
||||
paths: [b]
|
||||
}, M = require("module")) => {
|
||||
let f = M._findPath(r, M._nodeModulePaths(b).concat(b));
|
||||
|
||||
if (f) return f;
|
||||
f = new Error(`Cannot resolve module '${r}'`);
|
||||
f.code = "MODULE_NOT_FOUND";
|
||||
@@ -165,11 +136,9 @@ function tryRequireResolve(id, {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function tryImportMetaResolve(_x, _x2) {
|
||||
return _tryImportMetaResolve.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _tryImportMetaResolve() {
|
||||
_tryImportMetaResolve = _asyncToGenerator(function* (id, options) {
|
||||
try {
|
||||
@@ -186,50 +155,40 @@ function _tryImportMetaResolve() {
|
||||
});
|
||||
return _tryImportMetaResolve.apply(this, arguments);
|
||||
}
|
||||
|
||||
function resolveStandardizedNameForRequire(type, name, dirname) {
|
||||
const it = resolveAlternativesHelper(type, name);
|
||||
let res = it.next();
|
||||
|
||||
while (!res.done) {
|
||||
res = it.next(tryRequireResolve(res.value, {
|
||||
paths: [dirname]
|
||||
}));
|
||||
}
|
||||
|
||||
return res.value;
|
||||
}
|
||||
|
||||
function resolveStandardizedNameForImport(_x3, _x4, _x5) {
|
||||
return _resolveStandardizedNameForImport.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _resolveStandardizedNameForImport() {
|
||||
_resolveStandardizedNameForImport = _asyncToGenerator(function* (type, name, dirname) {
|
||||
const parentUrl = (0, _url().pathToFileURL)(_path().join(dirname, "./babel-virtual-resolve-base.js")).href;
|
||||
const it = resolveAlternativesHelper(type, name);
|
||||
let res = it.next();
|
||||
|
||||
while (!res.done) {
|
||||
res = it.next(yield tryImportMetaResolve(res.value, parentUrl));
|
||||
}
|
||||
|
||||
return (0, _url().fileURLToPath)(res.value);
|
||||
});
|
||||
return _resolveStandardizedNameForImport.apply(this, arguments);
|
||||
}
|
||||
|
||||
const resolveStandardizedName = _gensync()({
|
||||
sync(type, name, dirname = process.cwd()) {
|
||||
return resolveStandardizedNameForRequire(type, name, dirname);
|
||||
},
|
||||
|
||||
async(type, name, dirname = process.cwd()) {
|
||||
return _asyncToGenerator(function* () {
|
||||
if (!_moduleTypes.supportsESM) {
|
||||
return resolveStandardizedNameForRequire(type, name, dirname);
|
||||
}
|
||||
|
||||
try {
|
||||
return yield resolveStandardizedNameForImport(type, name, dirname);
|
||||
} catch (e) {
|
||||
@@ -243,25 +202,22 @@ const resolveStandardizedName = _gensync()({
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
{
|
||||
var LOADING_MODULES = new Set();
|
||||
}
|
||||
|
||||
function* requireModule(type, name) {
|
||||
{
|
||||
if (!(yield* (0, _async.isAsync)()) && LOADING_MODULES.has(name)) {
|
||||
throw new Error(`Reentrant ${type} detected trying to load "${name}". This module is not ignored ` + "and is trying to load itself while compiling itself, leading to a dependency cycle. " + 'We recommend adding it to your "ignore" list in your babelrc, or to a .babelignore.');
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
{
|
||||
LOADING_MODULES.add(name);
|
||||
}
|
||||
return yield* (0, _moduleTypes.default)(name, `You appear to be using a native ECMAScript module ${type}, ` + "which is only supported when running Babel asynchronously.", true);
|
||||
return yield* (0, _moduleTypes.default)(name, `You appear to be using a native ECMAScript module ${type}, ` + "which is only supported when running Babel asynchronously.",
|
||||
true);
|
||||
} catch (err) {
|
||||
err.message = `[BABEL]: ${err.message} (While processing: ${name})`;
|
||||
throw err;
|
||||
@@ -271,7 +227,6 @@ function* requireModule(type, name) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=plugins.js.map
|
||||
|
||||
12
tools/node_modules/eslint/node_modules/@babel/core/lib/config/files/utils.js
generated
vendored
12
tools/node_modules/eslint/node_modules/@babel/core/lib/config/files/utils.js
generated
vendored
@@ -4,45 +4,33 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.makeStaticFileCache = makeStaticFileCache;
|
||||
|
||||
var _caching = require("../caching");
|
||||
|
||||
var fs = require("../../gensync-utils/fs");
|
||||
|
||||
function _fs2() {
|
||||
const data = require("fs");
|
||||
|
||||
_fs2 = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function makeStaticFileCache(fn) {
|
||||
return (0, _caching.makeStrongCache)(function* (filepath, cache) {
|
||||
const cached = cache.invalidate(() => fileMtime(filepath));
|
||||
|
||||
if (cached === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return fn(filepath, yield* fs.readFile(filepath, "utf8"));
|
||||
});
|
||||
}
|
||||
|
||||
function fileMtime(filepath) {
|
||||
if (!_fs2().existsSync(filepath)) return null;
|
||||
|
||||
try {
|
||||
return +_fs2().statSync(filepath).mtime;
|
||||
} catch (e) {
|
||||
if (e.code !== "ENOENT" && e.code !== "ENOTDIR") throw e;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=utils.js.map
|
||||
|
||||
103
tools/node_modules/eslint/node_modules/@babel/core/lib/config/full.js
generated
vendored
103
tools/node_modules/eslint/node_modules/@babel/core/lib/config/full.js
generated
vendored
@@ -4,96 +4,65 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _gensync() {
|
||||
const data = require("gensync");
|
||||
|
||||
_gensync = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _async = require("../gensync-utils/async");
|
||||
|
||||
var _util = require("./util");
|
||||
|
||||
var context = require("../index");
|
||||
|
||||
var _plugin = require("./plugin");
|
||||
|
||||
var _item = require("./item");
|
||||
|
||||
var _configChain = require("./config-chain");
|
||||
|
||||
var _deepArray = require("./helpers/deep-array");
|
||||
|
||||
function _traverse() {
|
||||
const data = require("@babel/traverse");
|
||||
|
||||
_traverse = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _caching = require("./caching");
|
||||
|
||||
var _options = require("./validation/options");
|
||||
|
||||
var _plugins = require("./validation/plugins");
|
||||
|
||||
var _configApi = require("./helpers/config-api");
|
||||
|
||||
var _partial = require("./partial");
|
||||
|
||||
var _configError = require("../errors/config-error");
|
||||
|
||||
var _default = _gensync()(function* loadFullConfig(inputOpts) {
|
||||
var _opts$assumptions;
|
||||
|
||||
const result = yield* (0, _partial.default)(inputOpts);
|
||||
|
||||
if (!result) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const {
|
||||
options,
|
||||
context,
|
||||
fileHandling
|
||||
} = result;
|
||||
|
||||
if (fileHandling === "ignored") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const optionDefaults = {};
|
||||
const {
|
||||
plugins,
|
||||
presets
|
||||
} = options;
|
||||
|
||||
if (!plugins || !presets) {
|
||||
throw new Error("Assertion failure - plugins and presets exist");
|
||||
}
|
||||
|
||||
const presetContext = Object.assign({}, context, {
|
||||
targets: options.targets
|
||||
});
|
||||
|
||||
const toDescriptor = item => {
|
||||
const desc = (0, _item.getItemDescriptor)(item);
|
||||
|
||||
if (!desc) {
|
||||
throw new Error("Assertion failure - must be config item");
|
||||
}
|
||||
|
||||
return desc;
|
||||
};
|
||||
|
||||
const presetsDescriptors = presets.map(toDescriptor);
|
||||
const initialPluginsDescriptors = plugins.map(toDescriptor);
|
||||
const pluginDescriptorsByPass = [[]];
|
||||
@@ -101,10 +70,8 @@ var _default = _gensync()(function* loadFullConfig(inputOpts) {
|
||||
const externalDependencies = [];
|
||||
const ignored = yield* enhanceError(context, function* recursePresetDescriptors(rawPresets, pluginDescriptorsPass) {
|
||||
const presets = [];
|
||||
|
||||
for (let i = 0; i < rawPresets.length; i++) {
|
||||
const descriptor = rawPresets[i];
|
||||
|
||||
if (descriptor.options !== false) {
|
||||
try {
|
||||
var preset = yield* loadPresetDescriptor(descriptor, presetContext);
|
||||
@@ -112,10 +79,8 @@ var _default = _gensync()(function* loadFullConfig(inputOpts) {
|
||||
if (e.code === "BABEL_UNKNOWN_OPTION") {
|
||||
(0, _options.checkNoUnwrappedItemOptionPairs)(rawPresets, i, "preset", e);
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
externalDependencies.push(preset.externalDependencies);
|
||||
|
||||
if (descriptor.ownPass) {
|
||||
@@ -134,7 +99,6 @@ var _default = _gensync()(function* loadFullConfig(inputOpts) {
|
||||
|
||||
if (presets.length > 0) {
|
||||
pluginDescriptorsByPass.splice(1, 0, ...presets.map(o => o.pass).filter(p => p !== pluginDescriptorsPass));
|
||||
|
||||
for (const {
|
||||
preset,
|
||||
pass
|
||||
@@ -157,14 +121,11 @@ var _default = _gensync()(function* loadFullConfig(inputOpts) {
|
||||
});
|
||||
yield* enhanceError(context, function* loadPluginDescriptors() {
|
||||
pluginDescriptorsByPass[0].unshift(...initialPluginsDescriptors);
|
||||
|
||||
for (const descs of pluginDescriptorsByPass) {
|
||||
const pass = [];
|
||||
passes.push(pass);
|
||||
|
||||
for (let i = 0; i < descs.length; i++) {
|
||||
const descriptor = descs[i];
|
||||
|
||||
if (descriptor.options !== false) {
|
||||
try {
|
||||
var plugin = yield* loadPluginDescriptor(descriptor, pluginContext);
|
||||
@@ -172,10 +133,8 @@ var _default = _gensync()(function* loadFullConfig(inputOpts) {
|
||||
if (e.code === "BABEL_UNKNOWN_PLUGIN_PROPERTY") {
|
||||
(0, _options.checkNoUnwrappedItemOptionPairs)(descs, i, "plugin", e);
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
pass.push(plugin);
|
||||
externalDependencies.push(plugin.externalDependencies);
|
||||
}
|
||||
@@ -193,9 +152,7 @@ var _default = _gensync()(function* loadFullConfig(inputOpts) {
|
||||
externalDependencies: (0, _deepArray.finalize)(externalDependencies)
|
||||
};
|
||||
});
|
||||
|
||||
exports.default = _default;
|
||||
|
||||
function enhanceError(context, fn) {
|
||||
return function* (arg1, arg2) {
|
||||
try {
|
||||
@@ -203,10 +160,8 @@ function enhanceError(context, fn) {
|
||||
} catch (e) {
|
||||
if (!/^\[BABEL\]/.test(e.message)) {
|
||||
var _context$filename;
|
||||
|
||||
e.message = `[BABEL] ${(_context$filename = context.filename) != null ? _context$filename : "unknown file"}: ${e.message}`;
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
@@ -222,44 +177,35 @@ const makeDescriptorLoader = apiFactory => (0, _caching.makeWeakCache)(function*
|
||||
options = options || {};
|
||||
const externalDependencies = [];
|
||||
let item = value;
|
||||
|
||||
if (typeof value === "function") {
|
||||
const factory = (0, _async.maybeAsync)(value, `You appear to be using an async plugin/preset, but Babel has been called synchronously`);
|
||||
const api = Object.assign({}, context, apiFactory(cache, externalDependencies));
|
||||
|
||||
try {
|
||||
item = yield* factory(api, options, dirname);
|
||||
} catch (e) {
|
||||
if (alias) {
|
||||
e.message += ` (While processing: ${JSON.stringify(alias)})`;
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
if (!item || typeof item !== "object") {
|
||||
throw new Error("Plugin/Preset did not return an object.");
|
||||
}
|
||||
|
||||
if ((0, _async.isThenable)(item)) {
|
||||
yield* [];
|
||||
throw new Error(`You appear to be using a promise as a plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, ` + `you may need to upgrade your @babel/core version. ` + `As an alternative, you can prefix the promise with "await". ` + `(While processing: ${JSON.stringify(alias)})`);
|
||||
}
|
||||
|
||||
if (externalDependencies.length > 0 && (!cache.configured() || cache.mode() === "forever")) {
|
||||
let error = `A plugin/preset has external untracked dependencies ` + `(${externalDependencies[0]}), but the cache `;
|
||||
|
||||
if (!cache.configured()) {
|
||||
error += `has not been configured to be invalidated when the external dependencies change. `;
|
||||
} else {
|
||||
error += ` has been configured to never be invalidated. `;
|
||||
}
|
||||
|
||||
error += `Plugins/presets should configure their cache to be invalidated when the external ` + `dependencies change, for example using \`api.cache.invalidate(() => ` + `statSync(filepath).mtimeMs)\` or \`api.cache.never()\`\n` + `(While processing: ${JSON.stringify(alias)})`;
|
||||
throw new Error(error);
|
||||
}
|
||||
|
||||
return {
|
||||
value: item,
|
||||
options,
|
||||
@@ -268,22 +214,8 @@ const makeDescriptorLoader = apiFactory => (0, _caching.makeWeakCache)(function*
|
||||
externalDependencies: (0, _deepArray.finalize)(externalDependencies)
|
||||
};
|
||||
});
|
||||
|
||||
const pluginDescriptorLoader = makeDescriptorLoader(_configApi.makePluginAPI);
|
||||
const presetDescriptorLoader = makeDescriptorLoader(_configApi.makePresetAPI);
|
||||
|
||||
function* loadPluginDescriptor(descriptor, context) {
|
||||
if (descriptor.value instanceof _plugin.default) {
|
||||
if (descriptor.options) {
|
||||
throw new Error("Passed options to an existing Plugin instance will not work.");
|
||||
}
|
||||
|
||||
return descriptor.value;
|
||||
}
|
||||
|
||||
return yield* instantiatePlugin(yield* pluginDescriptorLoader(descriptor, context), context);
|
||||
}
|
||||
|
||||
const instantiatePlugin = (0, _caching.makeWeakCache)(function* ({
|
||||
value,
|
||||
options,
|
||||
@@ -293,11 +225,9 @@ const instantiatePlugin = (0, _caching.makeWeakCache)(function* ({
|
||||
}, cache) {
|
||||
const pluginObj = (0, _plugins.validatePluginObject)(value);
|
||||
const plugin = Object.assign({}, pluginObj);
|
||||
|
||||
if (plugin.visitor) {
|
||||
plugin.visitor = _traverse().default.explode(Object.assign({}, plugin.visitor));
|
||||
}
|
||||
|
||||
if (plugin.inherits) {
|
||||
const inheritsDescriptor = {
|
||||
name: undefined,
|
||||
@@ -313,7 +243,6 @@ const instantiatePlugin = (0, _caching.makeWeakCache)(function* ({
|
||||
plugin.post = chain(inherits.post, plugin.post);
|
||||
plugin.manipulateOptions = chain(inherits.manipulateOptions, plugin.manipulateOptions);
|
||||
plugin.visitor = _traverse().default.visitors.merge([inherits.visitor || {}, plugin.visitor || {}]);
|
||||
|
||||
if (inherits.externalDependencies.length > 0) {
|
||||
if (externalDependencies.length === 0) {
|
||||
externalDependencies = inherits.externalDependencies;
|
||||
@@ -322,41 +251,36 @@ const instantiatePlugin = (0, _caching.makeWeakCache)(function* ({
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new _plugin.default(plugin, options, alias, externalDependencies);
|
||||
});
|
||||
|
||||
function* loadPluginDescriptor(descriptor, context) {
|
||||
if (descriptor.value instanceof _plugin.default) {
|
||||
if (descriptor.options) {
|
||||
throw new Error("Passed options to an existing Plugin instance will not work.");
|
||||
}
|
||||
return descriptor.value;
|
||||
}
|
||||
return yield* instantiatePlugin(yield* pluginDescriptorLoader(descriptor, context), context);
|
||||
}
|
||||
const needsFilename = val => val && typeof val !== "function";
|
||||
|
||||
const validateIfOptionNeedsFilename = (options, descriptor) => {
|
||||
if (needsFilename(options.test) || needsFilename(options.include) || needsFilename(options.exclude)) {
|
||||
const formattedPresetName = descriptor.name ? `"${descriptor.name}"` : "/* your preset */";
|
||||
throw new _configError.default([`Preset ${formattedPresetName} requires a filename to be set when babel is called directly,`, `\`\`\``, `babel.transformSync(code, { filename: 'file.ts', presets: [${formattedPresetName}] });`, `\`\`\``, `See https://babeljs.io/docs/en/options#filename for more information.`].join("\n"));
|
||||
}
|
||||
};
|
||||
|
||||
const validatePreset = (preset, context, descriptor) => {
|
||||
if (!context.filename) {
|
||||
const {
|
||||
options
|
||||
} = preset;
|
||||
validateIfOptionNeedsFilename(options, descriptor);
|
||||
|
||||
if (options.overrides) {
|
||||
options.overrides.forEach(overrideOptions => validateIfOptionNeedsFilename(overrideOptions, descriptor));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function* loadPresetDescriptor(descriptor, context) {
|
||||
const preset = instantiatePreset(yield* presetDescriptorLoader(descriptor, context));
|
||||
validatePreset(preset, context, descriptor);
|
||||
return {
|
||||
chain: yield* (0, _configChain.buildPresetChain)(preset, context),
|
||||
externalDependencies: preset.externalDependencies
|
||||
};
|
||||
}
|
||||
|
||||
const instantiatePreset = (0, _caching.makeWeakCacheSync)(({
|
||||
value,
|
||||
dirname,
|
||||
@@ -371,6 +295,14 @@ const instantiatePreset = (0, _caching.makeWeakCacheSync)(({
|
||||
};
|
||||
});
|
||||
|
||||
function* loadPresetDescriptor(descriptor, context) {
|
||||
const preset = instantiatePreset(yield* presetDescriptorLoader(descriptor, context));
|
||||
validatePreset(preset, context, descriptor);
|
||||
return {
|
||||
chain: yield* (0, _configChain.buildPresetChain)(preset, context),
|
||||
externalDependencies: preset.externalDependencies
|
||||
};
|
||||
}
|
||||
function chain(a, b) {
|
||||
const fns = [a, b].filter(Boolean);
|
||||
if (fns.length <= 1) return fns[0];
|
||||
@@ -380,7 +312,6 @@ function chain(a, b) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=full.js.map
|
||||
|
||||
28
tools/node_modules/eslint/node_modules/@babel/core/lib/config/helpers/config-api.js
generated
vendored
28
tools/node_modules/eslint/node_modules/@babel/core/lib/config/helpers/config-api.js
generated
vendored
@@ -6,40 +6,29 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.makeConfigAPI = makeConfigAPI;
|
||||
exports.makePluginAPI = makePluginAPI;
|
||||
exports.makePresetAPI = makePresetAPI;
|
||||
|
||||
function _semver() {
|
||||
const data = require("semver");
|
||||
|
||||
_semver = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _ = require("../../");
|
||||
|
||||
var _caching = require("../caching");
|
||||
|
||||
function makeConfigAPI(cache) {
|
||||
const env = value => cache.using(data => {
|
||||
if (typeof value === "undefined") return data.envName;
|
||||
|
||||
if (typeof value === "function") {
|
||||
return (0, _caching.assertSimpleType)(value(data.envName));
|
||||
}
|
||||
|
||||
return (Array.isArray(value) ? value : [value]).some(entry => {
|
||||
if (typeof entry !== "string") {
|
||||
throw new Error("Unexpected non-string value");
|
||||
}
|
||||
|
||||
return entry === data.envName;
|
||||
});
|
||||
});
|
||||
|
||||
const caller = cb => cache.using(data => (0, _caching.assertSimpleType)(cb(data.caller)));
|
||||
|
||||
return {
|
||||
version: _.version,
|
||||
cache: cache.simple(),
|
||||
@@ -49,61 +38,48 @@ function makeConfigAPI(cache) {
|
||||
assertVersion
|
||||
};
|
||||
}
|
||||
|
||||
function makePresetAPI(cache, externalDependencies) {
|
||||
const targets = () => JSON.parse(cache.using(data => JSON.stringify(data.targets)));
|
||||
|
||||
const targets = () =>
|
||||
JSON.parse(cache.using(data => JSON.stringify(data.targets)));
|
||||
const addExternalDependency = ref => {
|
||||
externalDependencies.push(ref);
|
||||
};
|
||||
|
||||
return Object.assign({}, makeConfigAPI(cache), {
|
||||
targets,
|
||||
addExternalDependency
|
||||
});
|
||||
}
|
||||
|
||||
function makePluginAPI(cache, externalDependencies) {
|
||||
const assumption = name => cache.using(data => data.assumptions[name]);
|
||||
|
||||
return Object.assign({}, makePresetAPI(cache, externalDependencies), {
|
||||
assumption
|
||||
});
|
||||
}
|
||||
|
||||
function assertVersion(range) {
|
||||
if (typeof range === "number") {
|
||||
if (!Number.isInteger(range)) {
|
||||
throw new Error("Expected string or integer value.");
|
||||
}
|
||||
|
||||
range = `^${range}.0.0-0`;
|
||||
}
|
||||
|
||||
if (typeof range !== "string") {
|
||||
throw new Error("Expected string or integer value.");
|
||||
}
|
||||
|
||||
if (_semver().satisfies(_.version, range)) return;
|
||||
const limit = Error.stackTraceLimit;
|
||||
|
||||
if (typeof limit === "number" && limit < 25) {
|
||||
Error.stackTraceLimit = 25;
|
||||
}
|
||||
|
||||
const err = new Error(`Requires Babel "${range}", but was loaded with "${_.version}". ` + `If you are sure you have a compatible version of @babel/core, ` + `it is likely that something in your build process is loading the ` + `wrong version. Inspect the stack trace of this error to look for ` + `the first entry that doesn't mention "@babel/core" or "babel-core" ` + `to see what is calling Babel.`);
|
||||
|
||||
if (typeof limit === "number") {
|
||||
Error.stackTraceLimit = limit;
|
||||
}
|
||||
|
||||
throw Object.assign(err, {
|
||||
code: "BABEL_VERSION_UNSUPPORTED",
|
||||
version: _.version,
|
||||
range
|
||||
});
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=config-api.js.map
|
||||
|
||||
4
tools/node_modules/eslint/node_modules/@babel/core/lib/config/helpers/deep-array.js
generated
vendored
4
tools/node_modules/eslint/node_modules/@babel/core/lib/config/helpers/deep-array.js
generated
vendored
@@ -9,20 +9,16 @@ exports.flattenToSet = flattenToSet;
|
||||
function finalize(deepArr) {
|
||||
return Object.freeze(deepArr);
|
||||
}
|
||||
|
||||
function flattenToSet(arr) {
|
||||
const result = new Set();
|
||||
const stack = [arr];
|
||||
|
||||
while (stack.length > 0) {
|
||||
for (const el of stack.pop()) {
|
||||
if (Array.isArray(el)) stack.push(el);else result.add(el);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=deep-array.js.map
|
||||
|
||||
2
tools/node_modules/eslint/node_modules/@babel/core/lib/config/helpers/environment.js
generated
vendored
2
tools/node_modules/eslint/node_modules/@babel/core/lib/config/helpers/environment.js
generated
vendored
@@ -4,11 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getEnv = getEnv;
|
||||
|
||||
function getEnv(defaultValue = "development") {
|
||||
return process.env.BABEL_ENV || process.env.NODE_ENV || defaultValue;
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=environment.js.map
|
||||
|
||||
15
tools/node_modules/eslint/node_modules/@babel/core/lib/config/index.js
generated
vendored
15
tools/node_modules/eslint/node_modules/@babel/core/lib/config/index.js
generated
vendored
@@ -12,36 +12,25 @@ Object.defineProperty(exports, "default", {
|
||||
}
|
||||
});
|
||||
exports.loadPartialConfigSync = exports.loadPartialConfigAsync = exports.loadPartialConfig = exports.loadOptionsSync = exports.loadOptionsAsync = exports.loadOptions = void 0;
|
||||
|
||||
function _gensync() {
|
||||
const data = require("gensync");
|
||||
|
||||
_gensync = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _full = require("./full");
|
||||
|
||||
var _partial = require("./partial");
|
||||
|
||||
var _item = require("./item");
|
||||
|
||||
const loadOptionsRunner = _gensync()(function* (opts) {
|
||||
var _config$options;
|
||||
|
||||
const config = yield* (0, _full.default)(opts);
|
||||
return (_config$options = config == null ? void 0 : config.options) != null ? _config$options : null;
|
||||
});
|
||||
|
||||
const createConfigItemRunner = _gensync()(_item.createConfigItem);
|
||||
|
||||
const maybeErrback = runner => (argOrCallback, maybeCallback) => {
|
||||
let arg;
|
||||
let callback;
|
||||
|
||||
if (maybeCallback === undefined && typeof argOrCallback === "function") {
|
||||
callback = argOrCallback;
|
||||
arg = undefined;
|
||||
@@ -49,10 +38,8 @@ const maybeErrback = runner => (argOrCallback, maybeCallback) => {
|
||||
callback = maybeCallback;
|
||||
arg = argOrCallback;
|
||||
}
|
||||
|
||||
return callback ? runner.errback(arg, callback) : runner.sync(arg);
|
||||
};
|
||||
|
||||
const loadPartialConfig = maybeErrback(_partial.loadPartialConfig);
|
||||
exports.loadPartialConfig = loadPartialConfig;
|
||||
const loadPartialConfigSync = _partial.loadPartialConfig.sync;
|
||||
@@ -69,7 +56,6 @@ const createConfigItemSync = createConfigItemRunner.sync;
|
||||
exports.createConfigItemSync = createConfigItemSync;
|
||||
const createConfigItemAsync = createConfigItemRunner.async;
|
||||
exports.createConfigItemAsync = createConfigItemAsync;
|
||||
|
||||
function createConfigItem(target, options, callback) {
|
||||
if (callback !== undefined) {
|
||||
return createConfigItemRunner.errback(target, options, callback);
|
||||
@@ -79,7 +65,6 @@ function createConfigItem(target, options, callback) {
|
||||
return createConfigItemRunner.sync(target, options);
|
||||
}
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
15
tools/node_modules/eslint/node_modules/@babel/core/lib/config/item.js
generated
vendored
15
tools/node_modules/eslint/node_modules/@babel/core/lib/config/item.js
generated
vendored
@@ -6,19 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.createConfigItem = createConfigItem;
|
||||
exports.createItemFromDescriptor = createItemFromDescriptor;
|
||||
exports.getItemDescriptor = getItemDescriptor;
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _configDescriptors = require("./config-descriptors");
|
||||
|
||||
function createItemFromDescriptor(desc) {
|
||||
return new ConfigItem(desc);
|
||||
}
|
||||
@@ -33,18 +28,15 @@ function* createConfigItem(value, {
|
||||
});
|
||||
return createItemFromDescriptor(descriptor);
|
||||
}
|
||||
|
||||
const CONFIG_ITEM_BRAND = Symbol.for("@babel/core@7 - ConfigItem");
|
||||
function getItemDescriptor(item) {
|
||||
if (item != null && item[CONFIG_ITEM_BRAND]) {
|
||||
return item._descriptor;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const CONFIG_ITEM_BRAND = Symbol.for("@babel/core@7 - ConfigItem");
|
||||
|
||||
class ConfigItem {
|
||||
|
||||
constructor(descriptor) {
|
||||
this._descriptor = void 0;
|
||||
this[CONFIG_ITEM_BRAND] = true;
|
||||
@@ -68,11 +60,10 @@ class ConfigItem {
|
||||
request: this._descriptor.file.request,
|
||||
resolved: this._descriptor.file.resolved
|
||||
} : undefined;
|
||||
|
||||
Object.freeze(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Object.freeze(ConfigItem.prototype);
|
||||
0 && 0;
|
||||
|
||||
|
||||
35
tools/node_modules/eslint/node_modules/@babel/core/lib/config/partial.js
generated
vendored
35
tools/node_modules/eslint/node_modules/@babel/core/lib/config/partial.js
generated
vendored
@@ -5,58 +5,39 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
exports.default = loadPrivatePartialConfig;
|
||||
exports.loadPartialConfig = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _gensync() {
|
||||
const data = require("gensync");
|
||||
|
||||
_gensync = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _plugin = require("./plugin");
|
||||
|
||||
var _util = require("./util");
|
||||
|
||||
var _item = require("./item");
|
||||
|
||||
var _configChain = require("./config-chain");
|
||||
|
||||
var _environment = require("./helpers/environment");
|
||||
|
||||
var _options = require("./validation/options");
|
||||
|
||||
var _files = require("./files");
|
||||
|
||||
var _resolveTargets = require("./resolve-targets");
|
||||
|
||||
const _excluded = ["showIgnoredFiles"];
|
||||
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
||||
|
||||
function resolveRootMode(rootDir, rootMode) {
|
||||
switch (rootMode) {
|
||||
case "root":
|
||||
return rootDir;
|
||||
|
||||
case "upward-optional":
|
||||
{
|
||||
const upwardRootDir = (0, _files.findConfigUpwards)(rootDir);
|
||||
return upwardRootDir === null ? rootDir : upwardRootDir;
|
||||
}
|
||||
|
||||
case "upward":
|
||||
{
|
||||
const upwardRootDir = (0, _files.findConfigUpwards)(rootDir);
|
||||
@@ -66,17 +47,14 @@ function resolveRootMode(rootDir, rootMode) {
|
||||
dirname: rootDir
|
||||
});
|
||||
}
|
||||
|
||||
default:
|
||||
throw new Error(`Assertion failure - unknown rootMode value.`);
|
||||
}
|
||||
}
|
||||
|
||||
function* loadPrivatePartialConfig(inputOpts) {
|
||||
if (inputOpts != null && (typeof inputOpts !== "object" || Array.isArray(inputOpts))) {
|
||||
throw new Error("Babel options must be an object, null, or undefined");
|
||||
}
|
||||
|
||||
const args = inputOpts ? (0, _options.validate)("arguments", inputOpts) : {};
|
||||
const {
|
||||
envName = (0, _environment.getEnv)(),
|
||||
@@ -86,9 +64,7 @@ function* loadPrivatePartialConfig(inputOpts) {
|
||||
caller,
|
||||
cloneInputAst = true
|
||||
} = args;
|
||||
|
||||
const absoluteCwd = _path().resolve(cwd);
|
||||
|
||||
const absoluteRootDir = resolveRootMode(_path().resolve(absoluteCwd, rootDir), rootMode);
|
||||
const filename = typeof args.filename === "string" ? _path().resolve(cwd, args.filename) : undefined;
|
||||
const showConfigPath = yield* (0, _files.resolveShowConfigPath)(absoluteCwd);
|
||||
@@ -133,10 +109,8 @@ function* loadPrivatePartialConfig(inputOpts) {
|
||||
files: configChain.files
|
||||
};
|
||||
}
|
||||
|
||||
const loadPartialConfig = _gensync()(function* (opts) {
|
||||
let showIgnoredFiles = false;
|
||||
|
||||
if (typeof opts === "object" && opts !== null && !Array.isArray(opts)) {
|
||||
var _opts = opts;
|
||||
({
|
||||
@@ -145,7 +119,6 @@ const loadPartialConfig = _gensync()(function* (opts) {
|
||||
opts = _objectWithoutPropertiesLoose(_opts, _excluded);
|
||||
_opts;
|
||||
}
|
||||
|
||||
const result = yield* loadPrivatePartialConfig(opts);
|
||||
if (!result) return null;
|
||||
const {
|
||||
@@ -156,11 +129,9 @@ const loadPartialConfig = _gensync()(function* (opts) {
|
||||
fileHandling,
|
||||
files
|
||||
} = result;
|
||||
|
||||
if (fileHandling === "ignored" && !showIgnoredFiles) {
|
||||
return null;
|
||||
}
|
||||
|
||||
(options.plugins || []).forEach(item => {
|
||||
if (item.value instanceof _plugin.default) {
|
||||
throw new Error("Passing cached plugin instances is not supported in " + "babel.loadPartialConfig()");
|
||||
@@ -168,10 +139,9 @@ const loadPartialConfig = _gensync()(function* (opts) {
|
||||
});
|
||||
return new PartialConfig(options, babelrc ? babelrc.filepath : undefined, ignore ? ignore.filepath : undefined, config ? config.filepath : undefined, fileHandling, files);
|
||||
});
|
||||
|
||||
exports.loadPartialConfig = loadPartialConfig;
|
||||
|
||||
class PartialConfig {
|
||||
|
||||
constructor(options, babelrc, ignore, config, fileHandling, files) {
|
||||
this.options = void 0;
|
||||
this.babelrc = void 0;
|
||||
@@ -185,15 +155,14 @@ class PartialConfig {
|
||||
this.config = config;
|
||||
this.fileHandling = fileHandling;
|
||||
this.files = files;
|
||||
|
||||
Object.freeze(this);
|
||||
}
|
||||
|
||||
hasFilesystemConfig() {
|
||||
return this.babelrc !== undefined || this.config !== undefined;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Object.freeze(PartialConfig.prototype);
|
||||
0 && 0;
|
||||
|
||||
|
||||
9
tools/node_modules/eslint/node_modules/@babel/core/lib/config/pattern-to-regex.js
generated
vendored
9
tools/node_modules/eslint/node_modules/@babel/core/lib/config/pattern-to-regex.js
generated
vendored
@@ -4,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = pathToPattern;
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
const sep = `\\${_path().sep}`;
|
||||
const endSep = `(?:${sep}|$)`;
|
||||
const substitution = `[^${sep}]+`;
|
||||
@@ -22,17 +18,17 @@ const starPat = `(?:${substitution}${sep})`;
|
||||
const starPatLast = `(?:${substitution}${endSep})`;
|
||||
const starStarPat = `${starPat}*?`;
|
||||
const starStarPatLast = `${starPat}*?${starPatLast}?`;
|
||||
|
||||
function escapeRegExp(string) {
|
||||
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&");
|
||||
}
|
||||
|
||||
function pathToPattern(pattern, dirname) {
|
||||
const parts = _path().resolve(dirname, pattern).split(_path().sep);
|
||||
|
||||
return new RegExp(["^", ...parts.map((part, i) => {
|
||||
const last = i === parts.length - 1;
|
||||
|
||||
if (part === "**") return last ? starStarPatLast : starStarPat;
|
||||
|
||||
if (part === "*") return last ? starPatLast : starPat;
|
||||
|
||||
if (part.indexOf("*.") === 0) {
|
||||
@@ -42,7 +38,6 @@ function pathToPattern(pattern, dirname) {
|
||||
return escapeRegExp(part) + (last ? endSep : sep);
|
||||
})].join(""));
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=pattern-to-regex.js.map
|
||||
|
||||
4
tools/node_modules/eslint/node_modules/@babel/core/lib/config/plugin.js
generated
vendored
4
tools/node_modules/eslint/node_modules/@babel/core/lib/config/plugin.js
generated
vendored
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _deepArray = require("./helpers/deep-array");
|
||||
|
||||
class Plugin {
|
||||
constructor(plugin, options, key, externalDependencies = (0, _deepArray.finalize)([])) {
|
||||
this.key = void 0;
|
||||
@@ -28,9 +26,7 @@ class Plugin {
|
||||
this.options = options;
|
||||
this.externalDependencies = externalDependencies;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = Plugin;
|
||||
0 && 0;
|
||||
|
||||
|
||||
28
tools/node_modules/eslint/node_modules/@babel/core/lib/config/printer.js
generated
vendored
28
tools/node_modules/eslint/node_modules/@babel/core/lib/config/printer.js
generated
vendored
@@ -4,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.ConfigPrinter = exports.ChainFormatter = void 0;
|
||||
|
||||
function _gensync() {
|
||||
const data = require("gensync");
|
||||
|
||||
_gensync = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
const ChainFormatter = {
|
||||
Programmatic: 0,
|
||||
Config: 1
|
||||
@@ -23,60 +19,44 @@ exports.ChainFormatter = ChainFormatter;
|
||||
const Formatter = {
|
||||
title(type, callerName, filepath) {
|
||||
let title = "";
|
||||
|
||||
if (type === ChainFormatter.Programmatic) {
|
||||
title = "programmatic options";
|
||||
|
||||
if (callerName) {
|
||||
title += " from " + callerName;
|
||||
}
|
||||
} else {
|
||||
title = "config " + filepath;
|
||||
}
|
||||
|
||||
return title;
|
||||
},
|
||||
|
||||
loc(index, envName) {
|
||||
let loc = "";
|
||||
|
||||
if (index != null) {
|
||||
loc += `.overrides[${index}]`;
|
||||
}
|
||||
|
||||
if (envName != null) {
|
||||
loc += `.env["${envName}"]`;
|
||||
}
|
||||
|
||||
return loc;
|
||||
},
|
||||
|
||||
*optionsAndDescriptors(opt) {
|
||||
const content = Object.assign({}, opt.options);
|
||||
delete content.overrides;
|
||||
delete content.env;
|
||||
const pluginDescriptors = [...(yield* opt.plugins())];
|
||||
|
||||
if (pluginDescriptors.length) {
|
||||
content.plugins = pluginDescriptors.map(d => descriptorToConfig(d));
|
||||
}
|
||||
|
||||
const presetDescriptors = [...(yield* opt.presets())];
|
||||
|
||||
if (presetDescriptors.length) {
|
||||
content.presets = [...presetDescriptors].map(d => descriptorToConfig(d));
|
||||
}
|
||||
|
||||
return JSON.stringify(content, undefined, 2);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function descriptorToConfig(d) {
|
||||
var _d$file;
|
||||
|
||||
let name = (_d$file = d.file) == null ? void 0 : _d$file.request;
|
||||
|
||||
if (name == null) {
|
||||
if (typeof d.value === "object") {
|
||||
name = d.value;
|
||||
@@ -84,11 +64,9 @@ function descriptorToConfig(d) {
|
||||
name = `[Function: ${d.value.toString().slice(0, 50)} ... ]`;
|
||||
}
|
||||
}
|
||||
|
||||
if (name == null) {
|
||||
name = "[Unknown]";
|
||||
}
|
||||
|
||||
if (d.options === undefined) {
|
||||
return name;
|
||||
} else if (d.name == null) {
|
||||
@@ -97,12 +75,10 @@ function descriptorToConfig(d) {
|
||||
return [name, d.options, d.name];
|
||||
}
|
||||
}
|
||||
|
||||
class ConfigPrinter {
|
||||
constructor() {
|
||||
this._stack = [];
|
||||
}
|
||||
|
||||
configure(enabled, type, {
|
||||
callerName,
|
||||
filepath
|
||||
@@ -119,7 +95,6 @@ class ConfigPrinter {
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
static *format(config) {
|
||||
let title = Formatter.title(config.type, config.callerName, config.filepath);
|
||||
const loc = Formatter.loc(config.index, config.envName);
|
||||
@@ -127,15 +102,12 @@ class ConfigPrinter {
|
||||
const content = yield* Formatter.optionsAndDescriptors(config.content);
|
||||
return `${title}\n${content}`;
|
||||
}
|
||||
|
||||
*output() {
|
||||
if (this._stack.length === 0) return "";
|
||||
const configs = yield* _gensync().all(this._stack.map(s => ConfigPrinter.format(s)));
|
||||
return configs.join("\n\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.ConfigPrinter = ConfigPrinter;
|
||||
0 && 0;
|
||||
|
||||
|
||||
15
tools/node_modules/eslint/node_modules/@babel/core/lib/config/resolve-targets-browser.js
generated
vendored
15
tools/node_modules/eslint/node_modules/@babel/core/lib/config/resolve-targets-browser.js
generated
vendored
@@ -5,25 +5,22 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
exports.resolveBrowserslistConfigFile = resolveBrowserslistConfigFile;
|
||||
exports.resolveTargets = resolveTargets;
|
||||
|
||||
function _helperCompilationTargets() {
|
||||
const data = require("@babel/helper-compilation-targets");
|
||||
|
||||
_helperCompilationTargets = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function resolveBrowserslistConfigFile(browserslistConfigFile, configFilePath) {
|
||||
function resolveBrowserslistConfigFile(
|
||||
browserslistConfigFile,
|
||||
configFilePath) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function resolveTargets(options, root) {
|
||||
function resolveTargets(options,
|
||||
root) {
|
||||
const optTargets = options.targets;
|
||||
let targets;
|
||||
|
||||
if (typeof optTargets === "string" || Array.isArray(optTargets)) {
|
||||
targets = {
|
||||
browsers: optTargets
|
||||
@@ -37,13 +34,11 @@ function resolveTargets(options, root) {
|
||||
targets = optTargets;
|
||||
}
|
||||
}
|
||||
|
||||
return (0, _helperCompilationTargets().default)(targets, {
|
||||
ignoreBrowserslistConfig: true,
|
||||
browserslistEnv: options.browserslistEnv
|
||||
});
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=resolve-targets-browser.js.map
|
||||
|
||||
14
tools/node_modules/eslint/node_modules/@babel/core/lib/config/resolve-targets.js
generated
vendored
14
tools/node_modules/eslint/node_modules/@babel/core/lib/config/resolve-targets.js
generated
vendored
@@ -5,37 +5,27 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
exports.resolveBrowserslistConfigFile = resolveBrowserslistConfigFile;
|
||||
exports.resolveTargets = resolveTargets;
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _helperCompilationTargets() {
|
||||
const data = require("@babel/helper-compilation-targets");
|
||||
|
||||
_helperCompilationTargets = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
({});
|
||||
|
||||
function resolveBrowserslistConfigFile(browserslistConfigFile, configFileDir) {
|
||||
return _path().resolve(configFileDir, browserslistConfigFile);
|
||||
}
|
||||
|
||||
function resolveTargets(options, root) {
|
||||
const optTargets = options.targets;
|
||||
let targets;
|
||||
|
||||
if (typeof optTargets === "string" || Array.isArray(optTargets)) {
|
||||
targets = {
|
||||
browsers: optTargets
|
||||
@@ -49,19 +39,16 @@ function resolveTargets(options, root) {
|
||||
targets = optTargets;
|
||||
}
|
||||
}
|
||||
|
||||
const {
|
||||
browserslistConfigFile
|
||||
} = options;
|
||||
let configFile;
|
||||
let ignoreBrowserslistConfig = false;
|
||||
|
||||
if (typeof browserslistConfigFile === "string") {
|
||||
configFile = browserslistConfigFile;
|
||||
} else {
|
||||
ignoreBrowserslistConfig = browserslistConfigFile === false;
|
||||
}
|
||||
|
||||
return (0, _helperCompilationTargets().default)(targets, {
|
||||
ignoreBrowserslistConfig,
|
||||
configFile,
|
||||
@@ -69,7 +56,6 @@ function resolveTargets(options, root) {
|
||||
browserslistEnv: options.browserslistEnv
|
||||
});
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=resolve-targets.js.map
|
||||
|
||||
4
tools/node_modules/eslint/node_modules/@babel/core/lib/config/util.js
generated
vendored
4
tools/node_modules/eslint/node_modules/@babel/core/lib/config/util.js
generated
vendored
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
exports.isIterableIterator = isIterableIterator;
|
||||
exports.mergeOptions = mergeOptions;
|
||||
|
||||
function mergeOptions(target, source) {
|
||||
for (const k of Object.keys(source)) {
|
||||
if ((k === "parserOpts" || k === "generatorOpts" || k === "assumptions") && source[k]) {
|
||||
@@ -18,18 +17,15 @@ function mergeOptions(target, source) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mergeDefaultFields(target, source) {
|
||||
for (const k of Object.keys(source)) {
|
||||
const val = source[k];
|
||||
if (val !== undefined) target[k] = val;
|
||||
}
|
||||
}
|
||||
|
||||
function isIterableIterator(value) {
|
||||
return !!value && typeof value.next === "function" && typeof value[Symbol.iterator] === "function";
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=util.js.map
|
||||
|
||||
@@ -23,41 +23,30 @@ exports.assertSourceType = assertSourceType;
|
||||
exports.assertString = assertString;
|
||||
exports.assertTargets = assertTargets;
|
||||
exports.msg = msg;
|
||||
|
||||
function _helperCompilationTargets() {
|
||||
const data = require("@babel/helper-compilation-targets");
|
||||
|
||||
_helperCompilationTargets = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _options = require("./options");
|
||||
|
||||
function msg(loc) {
|
||||
switch (loc.type) {
|
||||
case "root":
|
||||
return ``;
|
||||
|
||||
case "env":
|
||||
return `${msg(loc.parent)}.env["${loc.name}"]`;
|
||||
|
||||
case "overrides":
|
||||
return `${msg(loc.parent)}.overrides[${loc.index}]`;
|
||||
|
||||
case "option":
|
||||
return `${msg(loc.parent)}.${loc.name}`;
|
||||
|
||||
case "access":
|
||||
return `${msg(loc.parent)}[${JSON.stringify(loc.name)}]`;
|
||||
|
||||
default:
|
||||
throw new Error(`Assertion failure: Unknown type ${loc.type}`);
|
||||
}
|
||||
}
|
||||
|
||||
function access(loc, name) {
|
||||
return {
|
||||
type: "access",
|
||||
@@ -65,129 +54,97 @@ function access(loc, name) {
|
||||
parent: loc
|
||||
};
|
||||
}
|
||||
|
||||
function assertRootMode(loc, value) {
|
||||
if (value !== undefined && value !== "root" && value !== "upward" && value !== "upward-optional") {
|
||||
throw new Error(`${msg(loc)} must be a "root", "upward", "upward-optional" or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertSourceMaps(loc, value) {
|
||||
if (value !== undefined && typeof value !== "boolean" && value !== "inline" && value !== "both") {
|
||||
throw new Error(`${msg(loc)} must be a boolean, "inline", "both", or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertCompact(loc, value) {
|
||||
if (value !== undefined && typeof value !== "boolean" && value !== "auto") {
|
||||
throw new Error(`${msg(loc)} must be a boolean, "auto", or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertSourceType(loc, value) {
|
||||
if (value !== undefined && value !== "module" && value !== "script" && value !== "unambiguous") {
|
||||
throw new Error(`${msg(loc)} must be "module", "script", "unambiguous", or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertCallerMetadata(loc, value) {
|
||||
const obj = assertObject(loc, value);
|
||||
|
||||
if (obj) {
|
||||
if (typeof obj.name !== "string") {
|
||||
throw new Error(`${msg(loc)} set but does not contain "name" property string`);
|
||||
}
|
||||
|
||||
for (const prop of Object.keys(obj)) {
|
||||
const propLoc = access(loc, prop);
|
||||
const value = obj[prop];
|
||||
|
||||
if (value != null && typeof value !== "boolean" && typeof value !== "string" && typeof value !== "number") {
|
||||
throw new Error(`${msg(propLoc)} must be null, undefined, a boolean, a string, or a number.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertInputSourceMap(loc, value) {
|
||||
if (value !== undefined && typeof value !== "boolean" && (typeof value !== "object" || !value)) {
|
||||
throw new Error(`${msg(loc)} must be a boolean, object, or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertString(loc, value) {
|
||||
if (value !== undefined && typeof value !== "string") {
|
||||
throw new Error(`${msg(loc)} must be a string, or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertFunction(loc, value) {
|
||||
if (value !== undefined && typeof value !== "function") {
|
||||
throw new Error(`${msg(loc)} must be a function, or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertBoolean(loc, value) {
|
||||
if (value !== undefined && typeof value !== "boolean") {
|
||||
throw new Error(`${msg(loc)} must be a boolean, or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertObject(loc, value) {
|
||||
if (value !== undefined && (typeof value !== "object" || Array.isArray(value) || !value)) {
|
||||
throw new Error(`${msg(loc)} must be an object, or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertArray(loc, value) {
|
||||
if (value != null && !Array.isArray(value)) {
|
||||
throw new Error(`${msg(loc)} must be an array, or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertIgnoreList(loc, value) {
|
||||
const arr = assertArray(loc, value);
|
||||
|
||||
if (arr) {
|
||||
arr.forEach((item, i) => assertIgnoreItem(access(loc, i), item));
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
function assertIgnoreItem(loc, value) {
|
||||
if (typeof value !== "string" && typeof value !== "function" && !(value instanceof RegExp)) {
|
||||
throw new Error(`${msg(loc)} must be an array of string/Function/RegExp values, or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertConfigApplicableTest(loc, value) {
|
||||
if (value === undefined) return value;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach((item, i) => {
|
||||
if (!checkValidTest(item)) {
|
||||
@@ -197,25 +154,19 @@ function assertConfigApplicableTest(loc, value) {
|
||||
} else if (!checkValidTest(value)) {
|
||||
throw new Error(`${msg(loc)} must be a string/Function/RegExp, or an array of those`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function checkValidTest(value) {
|
||||
return typeof value === "string" || typeof value === "function" || value instanceof RegExp;
|
||||
}
|
||||
|
||||
function assertConfigFileSearch(loc, value) {
|
||||
if (value !== undefined && typeof value !== "boolean" && typeof value !== "string") {
|
||||
throw new Error(`${msg(loc)} must be a undefined, a boolean, a string, ` + `got ${JSON.stringify(value)}`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertBabelrcSearch(loc, value) {
|
||||
if (value === undefined || typeof value === "boolean") return value;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach((item, i) => {
|
||||
if (!checkValidTest(item)) {
|
||||
@@ -225,43 +176,32 @@ function assertBabelrcSearch(loc, value) {
|
||||
} else if (!checkValidTest(value)) {
|
||||
throw new Error(`${msg(loc)} must be a undefined, a boolean, a string/Function/RegExp ` + `or an array of those, got ${JSON.stringify(value)}`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertPluginList(loc, value) {
|
||||
const arr = assertArray(loc, value);
|
||||
|
||||
if (arr) {
|
||||
arr.forEach((item, i) => assertPluginItem(access(loc, i), item));
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
function assertPluginItem(loc, value) {
|
||||
if (Array.isArray(value)) {
|
||||
if (value.length === 0) {
|
||||
throw new Error(`${msg(loc)} must include an object`);
|
||||
}
|
||||
|
||||
if (value.length > 3) {
|
||||
throw new Error(`${msg(loc)} may only be a two-tuple or three-tuple`);
|
||||
}
|
||||
|
||||
assertPluginTarget(access(loc, 0), value[0]);
|
||||
|
||||
if (value.length > 1) {
|
||||
const opts = value[1];
|
||||
|
||||
if (opts !== undefined && opts !== false && (typeof opts !== "object" || Array.isArray(opts) || opts === null)) {
|
||||
throw new Error(`${msg(access(loc, 1))} must be an object, false, or undefined`);
|
||||
}
|
||||
}
|
||||
|
||||
if (value.length === 3) {
|
||||
const name = value[2];
|
||||
|
||||
if (name !== undefined && typeof name !== "string") {
|
||||
throw new Error(`${msg(access(loc, 2))} must be a string, or undefined`);
|
||||
}
|
||||
@@ -272,27 +212,21 @@ function assertPluginItem(loc, value) {
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertPluginTarget(loc, value) {
|
||||
if ((typeof value !== "object" || !value) && typeof value !== "string" && typeof value !== "function") {
|
||||
throw new Error(`${msg(loc)} must be a string, object, function`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertTargets(loc, value) {
|
||||
if ((0, _helperCompilationTargets().isBrowsersQueryValid)(value)) return value;
|
||||
|
||||
if (typeof value !== "object" || !value || Array.isArray(value)) {
|
||||
throw new Error(`${msg(loc)} must be a string, an array of strings or an object`);
|
||||
}
|
||||
|
||||
const browsersLoc = access(loc, "browsers");
|
||||
const esmodulesLoc = access(loc, "esmodules");
|
||||
assertBrowsersList(browsersLoc, value.browsers);
|
||||
assertBoolean(esmodulesLoc, value.esmodules);
|
||||
|
||||
for (const key of Object.keys(value)) {
|
||||
const val = value[key];
|
||||
const subLoc = access(loc, key);
|
||||
@@ -301,48 +235,37 @@ function assertTargets(loc, value) {
|
||||
throw new Error(`${msg(subLoc)} is not a valid target. Supported targets are ${validTargets}`);
|
||||
} else assertBrowserVersion(subLoc, val);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertBrowsersList(loc, value) {
|
||||
if (value !== undefined && !(0, _helperCompilationTargets().isBrowsersQueryValid)(value)) {
|
||||
throw new Error(`${msg(loc)} must be undefined, a string or an array of strings`);
|
||||
}
|
||||
}
|
||||
|
||||
function assertBrowserVersion(loc, value) {
|
||||
if (typeof value === "number" && Math.round(value) === value) return;
|
||||
if (typeof value === "string") return;
|
||||
throw new Error(`${msg(loc)} must be a string or an integer number`);
|
||||
}
|
||||
|
||||
function assertAssumptions(loc, value) {
|
||||
if (value === undefined) return;
|
||||
|
||||
if (typeof value !== "object" || value === null) {
|
||||
throw new Error(`${msg(loc)} must be an object or undefined.`);
|
||||
}
|
||||
|
||||
let root = loc;
|
||||
|
||||
do {
|
||||
root = root.parent;
|
||||
} while (root.type !== "root");
|
||||
|
||||
const inPreset = root.source === "preset";
|
||||
|
||||
for (const name of Object.keys(value)) {
|
||||
const subLoc = access(loc, name);
|
||||
|
||||
if (!_options.assumptionsNames.has(name)) {
|
||||
throw new Error(`${msg(subLoc)} is not a supported assumption.`);
|
||||
}
|
||||
|
||||
if (typeof value[name] !== "boolean") {
|
||||
throw new Error(`${msg(subLoc)} must be a boolean.`);
|
||||
}
|
||||
|
||||
if (inPreset && value[name] === false) {
|
||||
throw new Error(`${msg(subLoc)} cannot be set to 'false' inside presets.`);
|
||||
}
|
||||
@@ -350,7 +273,6 @@ function assertAssumptions(loc, value) {
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=option-assertions.js.map
|
||||
|
||||
28
tools/node_modules/eslint/node_modules/@babel/core/lib/config/validation/options.js
generated
vendored
28
tools/node_modules/eslint/node_modules/@babel/core/lib/config/validation/options.js
generated
vendored
@@ -6,13 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.assumptionsNames = void 0;
|
||||
exports.checkNoUnwrappedItemOptionPairs = checkNoUnwrappedItemOptionPairs;
|
||||
exports.validate = validate;
|
||||
|
||||
var _removed = require("./removed");
|
||||
|
||||
var _optionAssertions = require("./option-assertions");
|
||||
|
||||
var _configError = require("../../errors/config-error");
|
||||
|
||||
const ROOT_VALIDATORS = {
|
||||
cwd: _optionAssertions.assertString,
|
||||
root: _optionAssertions.assertString,
|
||||
@@ -77,11 +73,9 @@ const COMMON_VALIDATORS = {
|
||||
const knownAssumptions = ["arrayLikeIsIterable", "constantReexports", "constantSuper", "enumerableModuleMeta", "ignoreFunctionLength", "ignoreToPrimitiveHint", "iterableIsArray", "mutableTemplateObject", "noClassCalls", "noDocumentAll", "noIncompleteNsImportDetection", "noNewArrows", "objectRestNoSymbols", "privateFieldsAsProperties", "pureGetters", "setClassMethods", "setComputedProperties", "setPublicClassFields", "setSpreadProperties", "skipForOfIteratorClosing", "superIsCallableConstructor"];
|
||||
const assumptionsNames = new Set(knownAssumptions);
|
||||
exports.assumptionsNames = assumptionsNames;
|
||||
|
||||
function getSource(loc) {
|
||||
return loc.type === "root" ? loc.source : getSource(loc.parent);
|
||||
}
|
||||
|
||||
function validate(type, opts, filename) {
|
||||
try {
|
||||
return validateNested({
|
||||
@@ -94,7 +88,6 @@ function validate(type, opts, filename) {
|
||||
throw configError;
|
||||
}
|
||||
}
|
||||
|
||||
function validateNested(loc, opts) {
|
||||
const type = getSource(loc);
|
||||
assertNoDuplicateSourcemap(opts);
|
||||
@@ -104,32 +97,25 @@ function validateNested(loc, opts) {
|
||||
name: key,
|
||||
parent: loc
|
||||
};
|
||||
|
||||
if (type === "preset" && NONPRESET_VALIDATORS[key]) {
|
||||
throw new Error(`${(0, _optionAssertions.msg)(optLoc)} is not allowed in preset options`);
|
||||
}
|
||||
|
||||
if (type !== "arguments" && ROOT_VALIDATORS[key]) {
|
||||
throw new Error(`${(0, _optionAssertions.msg)(optLoc)} is only allowed in root programmatic options`);
|
||||
}
|
||||
|
||||
if (type !== "arguments" && type !== "configfile" && BABELRC_VALIDATORS[key]) {
|
||||
if (type === "babelrcfile" || type === "extendsfile") {
|
||||
throw new Error(`${(0, _optionAssertions.msg)(optLoc)} is not allowed in .babelrc or "extends"ed files, only in root programmatic options, ` + `or babel.config.js/config file options`);
|
||||
}
|
||||
|
||||
throw new Error(`${(0, _optionAssertions.msg)(optLoc)} is only allowed in root programmatic options, or babel.config.js/config file options`);
|
||||
}
|
||||
|
||||
const validator = COMMON_VALIDATORS[key] || NONPRESET_VALIDATORS[key] || BABELRC_VALIDATORS[key] || ROOT_VALIDATORS[key] || throwUnknownError;
|
||||
validator(optLoc, opts[key]);
|
||||
});
|
||||
return opts;
|
||||
}
|
||||
|
||||
function throwUnknownError(loc) {
|
||||
const key = loc.name;
|
||||
|
||||
if (_removed.default[key]) {
|
||||
const {
|
||||
message,
|
||||
@@ -142,25 +128,20 @@ function throwUnknownError(loc) {
|
||||
throw unknownOptErr;
|
||||
}
|
||||
}
|
||||
|
||||
function has(obj, key) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, key);
|
||||
}
|
||||
|
||||
function assertNoDuplicateSourcemap(opts) {
|
||||
if (has(opts, "sourceMap") && has(opts, "sourceMaps")) {
|
||||
throw new Error(".sourceMap is an alias for .sourceMaps, cannot use both");
|
||||
}
|
||||
}
|
||||
|
||||
function assertEnvSet(loc, value) {
|
||||
if (loc.parent.type === "env") {
|
||||
throw new Error(`${(0, _optionAssertions.msg)(loc)} is not allowed inside of another .env block`);
|
||||
}
|
||||
|
||||
const parent = loc.parent;
|
||||
const obj = (0, _optionAssertions.assertObject)(loc, value);
|
||||
|
||||
if (obj) {
|
||||
for (const envName of Object.keys(obj)) {
|
||||
const env = (0, _optionAssertions.assertObject)((0, _optionAssertions.access)(loc, envName), obj[envName]);
|
||||
@@ -173,22 +154,17 @@ function assertEnvSet(loc, value) {
|
||||
validateNested(envLoc, env);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function assertOverridesList(loc, value) {
|
||||
if (loc.parent.type === "env") {
|
||||
throw new Error(`${(0, _optionAssertions.msg)(loc)} is not allowed inside an .env block`);
|
||||
}
|
||||
|
||||
if (loc.parent.type === "overrides") {
|
||||
throw new Error(`${(0, _optionAssertions.msg)(loc)} is not allowed inside an .overrides block`);
|
||||
}
|
||||
|
||||
const parent = loc.parent;
|
||||
const arr = (0, _optionAssertions.assertArray)(loc, value);
|
||||
|
||||
if (arr) {
|
||||
for (const [index, item] of arr.entries()) {
|
||||
const objLoc = (0, _optionAssertions.access)(loc, index);
|
||||
@@ -202,20 +178,16 @@ function assertOverridesList(loc, value) {
|
||||
validateNested(overridesLoc, env);
|
||||
}
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
function checkNoUnwrappedItemOptionPairs(items, index, type, e) {
|
||||
if (index === 0) return;
|
||||
const lastItem = items[index - 1];
|
||||
const thisItem = items[index];
|
||||
|
||||
if (lastItem.file && lastItem.options === undefined && typeof thisItem.value === "object") {
|
||||
e.message += `\n- Maybe you meant to use\n` + `"${type}s": [\n ["${lastItem.file.request}", ${JSON.stringify(thisItem.value, undefined, 2)}]\n]\n` + `To be a valid ${type}, its name and options should be wrapped in a pair of brackets`;
|
||||
}
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=options.js.map
|
||||
|
||||
11
tools/node_modules/eslint/node_modules/@babel/core/lib/config/validation/plugins.js
generated
vendored
11
tools/node_modules/eslint/node_modules/@babel/core/lib/config/validation/plugins.js
generated
vendored
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.validatePluginObject = validatePluginObject;
|
||||
|
||||
var _optionAssertions = require("./option-assertions");
|
||||
|
||||
const VALIDATORS = {
|
||||
name: _optionAssertions.assertString,
|
||||
manipulateOptions: _optionAssertions.assertFunction,
|
||||
@@ -17,21 +15,16 @@ const VALIDATORS = {
|
||||
parserOverride: _optionAssertions.assertFunction,
|
||||
generatorOverride: _optionAssertions.assertFunction
|
||||
};
|
||||
|
||||
function assertVisitorMap(loc, value) {
|
||||
const obj = (0, _optionAssertions.assertObject)(loc, value);
|
||||
|
||||
if (obj) {
|
||||
Object.keys(obj).forEach(prop => assertVisitorHandler(prop, obj[prop]));
|
||||
|
||||
if (obj.enter || obj.exit) {
|
||||
throw new Error(`${(0, _optionAssertions.msg)(loc)} cannot contain catch-all "enter" or "exit" handlers. Please target individual nodes.`);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function assertVisitorHandler(key, value) {
|
||||
if (value && typeof value === "object") {
|
||||
Object.keys(value).forEach(handler => {
|
||||
@@ -42,10 +35,8 @@ function assertVisitorHandler(key, value) {
|
||||
} else if (typeof value !== "function") {
|
||||
throw new Error(`.visitor["${key}"] must be a function`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function validatePluginObject(obj) {
|
||||
const rootPath = {
|
||||
type: "root",
|
||||
@@ -53,7 +44,6 @@ function validatePluginObject(obj) {
|
||||
};
|
||||
Object.keys(obj).forEach(key => {
|
||||
const validator = VALIDATORS[key];
|
||||
|
||||
if (validator) {
|
||||
const optLoc = {
|
||||
type: "option",
|
||||
@@ -69,7 +59,6 @@ function validatePluginObject(obj) {
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=plugins.js.map
|
||||
|
||||
4
tools/node_modules/eslint/node_modules/@babel/core/lib/errors/config-error.js
generated
vendored
4
tools/node_modules/eslint/node_modules/@babel/core/lib/errors/config-error.js
generated
vendored
@@ -4,18 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _rewriteStackTrace = require("./rewrite-stack-trace");
|
||||
|
||||
class ConfigError extends Error {
|
||||
constructor(message, filename) {
|
||||
super(message);
|
||||
(0, _rewriteStackTrace.expectedError)(this);
|
||||
if (filename) (0, _rewriteStackTrace.injcectVirtualStackFrame)(this, filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = ConfigError;
|
||||
0 && 0;
|
||||
|
||||
|
||||
16
tools/node_modules/eslint/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js
generated
vendored
16
tools/node_modules/eslint/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js
generated
vendored
@@ -7,13 +7,13 @@ exports.beginHiddenCallStack = beginHiddenCallStack;
|
||||
exports.endHiddenCallStack = endHiddenCallStack;
|
||||
exports.expectedError = expectedError;
|
||||
exports.injcectVirtualStackFrame = injcectVirtualStackFrame;
|
||||
|
||||
const ErrorToString = Function.call.bind(Error.prototype.toString);
|
||||
const SUPPORTED = !!Error.captureStackTrace;
|
||||
const START_HIDNG = "startHiding - secret - don't use this - v1";
|
||||
const STOP_HIDNG = "stopHiding - secret - don't use this - v1";
|
||||
const expectedErrors = new WeakSet();
|
||||
const virtualFrames = new WeakMap();
|
||||
|
||||
function CallSite(filename) {
|
||||
return Object.create({
|
||||
isNative: () => false,
|
||||
@@ -28,7 +28,6 @@ function CallSite(filename) {
|
||||
toString: () => filename
|
||||
});
|
||||
}
|
||||
|
||||
function injcectVirtualStackFrame(error, filename) {
|
||||
if (!SUPPORTED) return;
|
||||
let frames = virtualFrames.get(error);
|
||||
@@ -36,13 +35,11 @@ function injcectVirtualStackFrame(error, filename) {
|
||||
frames.push(CallSite(filename));
|
||||
return error;
|
||||
}
|
||||
|
||||
function expectedError(error) {
|
||||
if (!SUPPORTED) return;
|
||||
expectedErrors.add(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
function beginHiddenCallStack(fn) {
|
||||
if (!SUPPORTED) return fn;
|
||||
return Object.defineProperty(function (...args) {
|
||||
@@ -52,7 +49,6 @@ function beginHiddenCallStack(fn) {
|
||||
value: STOP_HIDNG
|
||||
});
|
||||
}
|
||||
|
||||
function endHiddenCallStack(fn) {
|
||||
if (!SUPPORTED) return fn;
|
||||
return Object.defineProperty(function (...args) {
|
||||
@@ -61,30 +57,25 @@ function endHiddenCallStack(fn) {
|
||||
value: START_HIDNG
|
||||
});
|
||||
}
|
||||
|
||||
function setupPrepareStackTrace() {
|
||||
setupPrepareStackTrace = () => {};
|
||||
|
||||
const {
|
||||
prepareStackTrace = defaultPrepareStackTrace
|
||||
} = Error;
|
||||
|
||||
const MIN_STACK_TRACE_LIMIT = 50;
|
||||
Error.stackTraceLimit && (Error.stackTraceLimit = Math.max(Error.stackTraceLimit, MIN_STACK_TRACE_LIMIT));
|
||||
|
||||
Error.prepareStackTrace = function stackTraceRewriter(err, trace) {
|
||||
let newTrace = [];
|
||||
const isExpected = expectedErrors.has(err);
|
||||
let status = isExpected ? "hiding" : "unknown";
|
||||
|
||||
for (let i = 0; i < trace.length; i++) {
|
||||
const name = trace[i].getFunctionName();
|
||||
|
||||
if (name === START_HIDNG) {
|
||||
status = "hiding";
|
||||
} else if (name === STOP_HIDNG) {
|
||||
if (status === "hiding") {
|
||||
status = "showing";
|
||||
|
||||
if (virtualFrames.has(err)) {
|
||||
newTrace.unshift(...virtualFrames.get(err));
|
||||
}
|
||||
@@ -96,16 +87,13 @@ function setupPrepareStackTrace() {
|
||||
newTrace.push(trace[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return prepareStackTrace(err, newTrace);
|
||||
};
|
||||
}
|
||||
|
||||
function defaultPrepareStackTrace(err, trace) {
|
||||
if (trace.length === 0) return ErrorToString(err);
|
||||
return `${ErrorToString(err)}\n at ${trace.join("\n at ")}`;
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=rewrite-stack-trace.js.map
|
||||
|
||||
18
tools/node_modules/eslint/node_modules/@babel/core/lib/gensync-utils/async.js
generated
vendored
18
tools/node_modules/eslint/node_modules/@babel/core/lib/gensync-utils/async.js
generated
vendored
@@ -8,21 +8,15 @@ exports.isAsync = void 0;
|
||||
exports.isThenable = isThenable;
|
||||
exports.maybeAsync = maybeAsync;
|
||||
exports.waitFor = exports.onFirstPause = void 0;
|
||||
|
||||
function _gensync() {
|
||||
const data = require("gensync");
|
||||
|
||||
_gensync = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
||||
|
||||
const runGenerator = _gensync()(function* (item) {
|
||||
return yield* item;
|
||||
});
|
||||
@@ -33,7 +27,6 @@ const isAsync = _gensync()({
|
||||
});
|
||||
|
||||
exports.isAsync = isAsync;
|
||||
|
||||
function maybeAsync(fn, message) {
|
||||
return _gensync()({
|
||||
sync(...args) {
|
||||
@@ -41,21 +34,17 @@ function maybeAsync(fn, message) {
|
||||
if (isThenable(result)) throw new Error(message);
|
||||
return result;
|
||||
},
|
||||
|
||||
async(...args) {
|
||||
return Promise.resolve(fn.apply(this, args));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
const withKind = _gensync()({
|
||||
sync: cb => cb("sync"),
|
||||
async: function () {
|
||||
var _ref = _asyncToGenerator(function* (cb) {
|
||||
return cb("async");
|
||||
});
|
||||
|
||||
return function async(_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
@@ -64,7 +53,6 @@ const withKind = _gensync()({
|
||||
|
||||
function forwardAsync(action, cb) {
|
||||
const g = _gensync()(action);
|
||||
|
||||
return withKind(kind => {
|
||||
const adapted = g[kind];
|
||||
return cb(adapted);
|
||||
@@ -83,7 +71,6 @@ const onFirstPause = _gensync()({
|
||||
completed = true;
|
||||
cb(err, value);
|
||||
});
|
||||
|
||||
if (!completed) {
|
||||
firstPause();
|
||||
}
|
||||
@@ -91,26 +78,21 @@ const onFirstPause = _gensync()({
|
||||
});
|
||||
|
||||
exports.onFirstPause = onFirstPause;
|
||||
|
||||
const waitFor = _gensync()({
|
||||
sync: x => x,
|
||||
async: function () {
|
||||
var _ref2 = _asyncToGenerator(function* (x) {
|
||||
return x;
|
||||
});
|
||||
|
||||
return function async(_x2) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
}()
|
||||
});
|
||||
|
||||
exports.waitFor = waitFor;
|
||||
|
||||
function isThenable(val) {
|
||||
return !!val && (typeof val === "object" || typeof val === "function") && !!val.then && typeof val.then === "function";
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=async.js.map
|
||||
|
||||
10
tools/node_modules/eslint/node_modules/@babel/core/lib/gensync-utils/fs.js
generated
vendored
10
tools/node_modules/eslint/node_modules/@babel/core/lib/gensync-utils/fs.js
generated
vendored
@@ -4,39 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.stat = exports.readFile = void 0;
|
||||
|
||||
function _fs() {
|
||||
const data = require("fs");
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _gensync() {
|
||||
const data = require("gensync");
|
||||
|
||||
_gensync = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
const readFile = _gensync()({
|
||||
sync: _fs().readFileSync,
|
||||
errback: _fs().readFile
|
||||
});
|
||||
|
||||
exports.readFile = readFile;
|
||||
|
||||
const stat = _gensync()({
|
||||
sync: _fs().statSync,
|
||||
errback: _fs().stat
|
||||
});
|
||||
|
||||
exports.stat = stat;
|
||||
0 && 0;
|
||||
|
||||
|
||||
4
tools/node_modules/eslint/node_modules/@babel/core/lib/gensync-utils/functional.js
generated
vendored
4
tools/node_modules/eslint/node_modules/@babel/core/lib/gensync-utils/functional.js
generated
vendored
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.once = once;
|
||||
|
||||
var _async = require("./async");
|
||||
|
||||
function once(fn) {
|
||||
let result;
|
||||
let resultP;
|
||||
@@ -19,7 +17,6 @@ function once(fn) {
|
||||
resolve = res;
|
||||
reject = rej;
|
||||
});
|
||||
|
||||
try {
|
||||
result = yield* fn();
|
||||
resultP = null;
|
||||
@@ -31,7 +28,6 @@ function once(fn) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=functional.js.map
|
||||
|
||||
31
tools/node_modules/eslint/node_modules/@babel/core/lib/index.js
generated
vendored
31
tools/node_modules/eslint/node_modules/@babel/core/lib/index.js
generated
vendored
@@ -181,90 +181,63 @@ Object.defineProperty((0, exports), "traverse", {
|
||||
}
|
||||
});
|
||||
exports.version = exports.types = void 0;
|
||||
|
||||
var _file = require("./transformation/file/file");
|
||||
|
||||
var _buildExternalHelpers = require("./tools/build-external-helpers");
|
||||
|
||||
var _files = require("./config/files");
|
||||
|
||||
var _environment = require("./config/helpers/environment");
|
||||
|
||||
function _types() {
|
||||
const data = require("@babel/types");
|
||||
|
||||
_types = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
Object.defineProperty((0, exports), "types", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _types();
|
||||
}
|
||||
});
|
||||
|
||||
function _parser() {
|
||||
const data = require("@babel/parser");
|
||||
|
||||
_parser = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _traverse() {
|
||||
const data = require("@babel/traverse");
|
||||
|
||||
_traverse = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _template() {
|
||||
const data = require("@babel/template");
|
||||
|
||||
_template = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _config = require("./config");
|
||||
|
||||
var _transform = require("./transform");
|
||||
|
||||
var _transformFile = require("./transform-file");
|
||||
|
||||
var _transformAst = require("./transform-ast");
|
||||
|
||||
var _parse = require("./parse");
|
||||
|
||||
const version = "7.19.6";
|
||||
const version = "7.20.2";
|
||||
exports.version = version;
|
||||
const DEFAULT_EXTENSIONS = Object.freeze([".js", ".jsx", ".es6", ".es", ".mjs", ".cjs"]);
|
||||
exports.DEFAULT_EXTENSIONS = DEFAULT_EXTENSIONS;
|
||||
|
||||
exports.DEFAULT_EXTENSIONS = DEFAULT_EXTENSIONS;
|
||||
class OptionManager {
|
||||
init(opts) {
|
||||
return (0, _config.loadOptionsSync)(opts);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.OptionManager = OptionManager;
|
||||
|
||||
function Plugin(alias) {
|
||||
throw new Error(`The (${alias}) Babel 5 plugin is being run with an unsupported Babel version.`);
|
||||
}
|
||||
|
||||
0 && (exports.types = exports.traverse = exports.tokTypes = exports.template = 0);
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
17
tools/node_modules/eslint/node_modules/@babel/core/lib/parse.js
generated
vendored
17
tools/node_modules/eslint/node_modules/@babel/core/lib/parse.js
generated
vendored
@@ -6,60 +6,43 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.parse = void 0;
|
||||
exports.parseAsync = parseAsync;
|
||||
exports.parseSync = parseSync;
|
||||
|
||||
function _gensync() {
|
||||
const data = require("gensync");
|
||||
|
||||
_gensync = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _config = require("./config");
|
||||
|
||||
var _parser = require("./parser");
|
||||
|
||||
var _normalizeOpts = require("./transformation/normalize-opts");
|
||||
|
||||
var _rewriteStackTrace = require("./errors/rewrite-stack-trace");
|
||||
|
||||
const parseRunner = _gensync()(function* parse(code, opts) {
|
||||
const config = yield* (0, _config.default)(opts);
|
||||
|
||||
if (config === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return yield* (0, _parser.default)(config.passes, (0, _normalizeOpts.default)(config), code);
|
||||
});
|
||||
|
||||
const parse = function parse(code, opts, callback) {
|
||||
if (typeof opts === "function") {
|
||||
callback = opts;
|
||||
opts = undefined;
|
||||
}
|
||||
|
||||
if (callback === undefined) {
|
||||
{
|
||||
return (0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.sync)(code, opts);
|
||||
}
|
||||
}
|
||||
|
||||
(0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.errback)(code, opts, callback);
|
||||
};
|
||||
|
||||
exports.parse = parse;
|
||||
|
||||
function parseSync(...args) {
|
||||
return (0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.sync)(...args);
|
||||
}
|
||||
|
||||
function parseAsync(...args) {
|
||||
return (0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.async)(...args);
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=parse.js.map
|
||||
|
||||
19
tools/node_modules/eslint/node_modules/@babel/core/lib/parser/index.js
generated
vendored
19
tools/node_modules/eslint/node_modules/@babel/core/lib/parser/index.js
generated
vendored
@@ -4,29 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = parser;
|
||||
|
||||
function _parser() {
|
||||
const data = require("@babel/parser");
|
||||
|
||||
_parser = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _codeFrame() {
|
||||
const data = require("@babel/code-frame");
|
||||
|
||||
_codeFrame = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _missingPluginHelper = require("./util/missing-plugin-helper");
|
||||
|
||||
function* parser(pluginPasses, {
|
||||
parserOpts,
|
||||
highlightCode = true,
|
||||
@@ -34,32 +26,26 @@ function* parser(pluginPasses, {
|
||||
}, code) {
|
||||
try {
|
||||
const results = [];
|
||||
|
||||
for (const plugins of pluginPasses) {
|
||||
for (const plugin of plugins) {
|
||||
const {
|
||||
parserOverride
|
||||
} = plugin;
|
||||
|
||||
if (parserOverride) {
|
||||
const ast = parserOverride(code, parserOpts, _parser().parse);
|
||||
if (ast !== undefined) results.push(ast);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (results.length === 0) {
|
||||
return (0, _parser().parse)(code, parserOpts);
|
||||
} else if (results.length === 1) {
|
||||
yield* [];
|
||||
|
||||
if (typeof results[0].then === "function") {
|
||||
throw new Error(`You appear to be using an async parser plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`);
|
||||
}
|
||||
|
||||
return results[0];
|
||||
}
|
||||
|
||||
throw new Error("More than one plugin attempted to override parsing.");
|
||||
} catch (err) {
|
||||
if (err.code === "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED") {
|
||||
@@ -70,7 +56,6 @@ function* parser(pluginPasses, {
|
||||
loc,
|
||||
missingPlugin
|
||||
} = err;
|
||||
|
||||
if (loc) {
|
||||
const codeFrame = (0, _codeFrame().codeFrameColumns)(code, {
|
||||
start: {
|
||||
@@ -80,20 +65,16 @@ function* parser(pluginPasses, {
|
||||
}, {
|
||||
highlightCode
|
||||
});
|
||||
|
||||
if (missingPlugin) {
|
||||
err.message = `${filename}: ` + (0, _missingPluginHelper.default)(missingPlugin[0], loc, codeFrame);
|
||||
} else {
|
||||
err.message = `${filename}: ${err.message}\n\n` + codeFrame;
|
||||
}
|
||||
|
||||
err.code = "BABEL_PARSE_ERROR";
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
@@ -288,8 +288,8 @@ const pluginNameMap = {
|
||||
}
|
||||
}
|
||||
};
|
||||
pluginNameMap.privateIn.syntax = pluginNameMap.privateIn.transform;
|
||||
|
||||
pluginNameMap.privateIn.syntax = pluginNameMap.privateIn.transform;
|
||||
const getNameURLCombination = ({
|
||||
name,
|
||||
url
|
||||
@@ -298,16 +298,13 @@ const getNameURLCombination = ({
|
||||
function generateMissingPluginMessage(missingPluginName, loc, codeFrame) {
|
||||
let helpMessage = `Support for the experimental syntax '${missingPluginName}' isn't currently enabled ` + `(${loc.line}:${loc.column + 1}):\n\n` + codeFrame;
|
||||
const pluginInfo = pluginNameMap[missingPluginName];
|
||||
|
||||
if (pluginInfo) {
|
||||
const {
|
||||
syntax: syntaxPlugin,
|
||||
transform: transformPlugin
|
||||
} = pluginInfo;
|
||||
|
||||
if (syntaxPlugin) {
|
||||
const syntaxPluginInfo = getNameURLCombination(syntaxPlugin);
|
||||
|
||||
if (transformPlugin) {
|
||||
const transformPluginInfo = getNameURLCombination(transformPlugin);
|
||||
const sectionType = transformPlugin.name.startsWith("@babel/plugin") ? "plugins" : "presets";
|
||||
@@ -318,10 +315,8 @@ If you want to leave it as-is, add ${syntaxPluginInfo} to the 'plugins' section
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return helpMessage;
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=missing-plugin-helper.js.map
|
||||
|
||||
28
tools/node_modules/eslint/node_modules/@babel/core/lib/tools/build-external-helpers.js
generated
vendored
28
tools/node_modules/eslint/node_modules/@babel/core/lib/tools/build-external-helpers.js
generated
vendored
@@ -4,49 +4,35 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _default;
|
||||
|
||||
function helpers() {
|
||||
const data = require("@babel/helpers");
|
||||
|
||||
helpers = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _generator() {
|
||||
const data = require("@babel/generator");
|
||||
|
||||
_generator = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _template() {
|
||||
const data = require("@babel/template");
|
||||
|
||||
_template = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _t() {
|
||||
const data = require("@babel/types");
|
||||
|
||||
_t = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _file = require("../transformation/file/file");
|
||||
|
||||
const {
|
||||
arrayExpression,
|
||||
assignmentExpression,
|
||||
@@ -68,7 +54,6 @@ const {
|
||||
variableDeclaration,
|
||||
variableDeclarator
|
||||
} = _t();
|
||||
|
||||
const buildUmdWrapper = replacements => _template().default.statement`
|
||||
(function (root, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
@@ -82,17 +67,16 @@ const buildUmdWrapper = replacements => _template().default.statement`
|
||||
FACTORY_BODY
|
||||
});
|
||||
`(replacements);
|
||||
|
||||
function buildGlobal(allowlist) {
|
||||
const namespace = identifier("babelHelpers");
|
||||
const body = [];
|
||||
const container = functionExpression(null, [identifier("global")], blockStatement(body));
|
||||
const tree = program([expressionStatement(callExpression(container, [conditionalExpression(binaryExpression("===", unaryExpression("typeof", identifier("global")), stringLiteral("undefined")), identifier("self"), identifier("global"))]))]);
|
||||
const tree = program([expressionStatement(callExpression(container, [
|
||||
conditionalExpression(binaryExpression("===", unaryExpression("typeof", identifier("global")), stringLiteral("undefined")), identifier("self"), identifier("global"))]))]);
|
||||
body.push(variableDeclaration("var", [variableDeclarator(namespace, assignmentExpression("=", memberExpression(identifier("global"), namespace), objectExpression([])))]));
|
||||
buildHelpers(body, namespace, allowlist);
|
||||
return tree;
|
||||
}
|
||||
|
||||
function buildModule(allowlist) {
|
||||
const body = [];
|
||||
const refs = buildHelpers(body, null, allowlist);
|
||||
@@ -101,7 +85,6 @@ function buildModule(allowlist) {
|
||||
})));
|
||||
return program(body, [], "module");
|
||||
}
|
||||
|
||||
function buildUmd(allowlist) {
|
||||
const namespace = identifier("babelHelpers");
|
||||
const body = [];
|
||||
@@ -116,7 +99,6 @@ function buildUmd(allowlist) {
|
||||
UMD_ROOT: identifier("this")
|
||||
})]);
|
||||
}
|
||||
|
||||
function buildVar(allowlist) {
|
||||
const namespace = identifier("babelHelpers");
|
||||
const body = [];
|
||||
@@ -126,12 +108,10 @@ function buildVar(allowlist) {
|
||||
body.push(expressionStatement(namespace));
|
||||
return tree;
|
||||
}
|
||||
|
||||
function buildHelpers(body, namespace, allowlist) {
|
||||
const getHelperReference = name => {
|
||||
return namespace ? memberExpression(namespace, identifier(name)) : identifier(`_${name}`);
|
||||
};
|
||||
|
||||
const refs = {};
|
||||
helpers().list.forEach(function (name) {
|
||||
if (allowlist && allowlist.indexOf(name) < 0) return;
|
||||
@@ -144,7 +124,6 @@ function buildHelpers(body, namespace, allowlist) {
|
||||
});
|
||||
return refs;
|
||||
}
|
||||
|
||||
function _default(allowlist, outputType = "global") {
|
||||
let tree;
|
||||
const build = {
|
||||
@@ -153,16 +132,13 @@ function _default(allowlist, outputType = "global") {
|
||||
umd: buildUmd,
|
||||
var: buildVar
|
||||
}[outputType];
|
||||
|
||||
if (build) {
|
||||
tree = build(allowlist);
|
||||
} else {
|
||||
throw new Error(`Unsupported output type ${outputType}`);
|
||||
}
|
||||
|
||||
return (0, _generator().default)(tree).code;
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=build-external-helpers.js.map
|
||||
|
||||
15
tools/node_modules/eslint/node_modules/@babel/core/lib/transform-ast.js
generated
vendored
15
tools/node_modules/eslint/node_modules/@babel/core/lib/transform-ast.js
generated
vendored
@@ -6,34 +6,25 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.transformFromAst = void 0;
|
||||
exports.transformFromAstAsync = transformFromAstAsync;
|
||||
exports.transformFromAstSync = transformFromAstSync;
|
||||
|
||||
function _gensync() {
|
||||
const data = require("gensync");
|
||||
|
||||
_gensync = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _config = require("./config");
|
||||
|
||||
var _transformation = require("./transformation");
|
||||
|
||||
var _rewriteStackTrace = require("./errors/rewrite-stack-trace");
|
||||
|
||||
const transformFromAstRunner = _gensync()(function* (ast, code, opts) {
|
||||
const config = yield* (0, _config.default)(opts);
|
||||
if (config === null) return null;
|
||||
if (!ast) throw new Error("No AST given");
|
||||
return yield* (0, _transformation.run)(config, code, ast);
|
||||
});
|
||||
|
||||
const transformFromAst = function transformFromAst(ast, code, optsOrCallback, maybeCallback) {
|
||||
let opts;
|
||||
let callback;
|
||||
|
||||
if (typeof optsOrCallback === "function") {
|
||||
callback = optsOrCallback;
|
||||
opts = undefined;
|
||||
@@ -41,26 +32,20 @@ const transformFromAst = function transformFromAst(ast, code, optsOrCallback, ma
|
||||
opts = optsOrCallback;
|
||||
callback = maybeCallback;
|
||||
}
|
||||
|
||||
if (callback === undefined) {
|
||||
{
|
||||
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformFromAstRunner.sync)(ast, code, opts);
|
||||
}
|
||||
}
|
||||
|
||||
(0, _rewriteStackTrace.beginHiddenCallStack)(transformFromAstRunner.errback)(ast, code, opts, callback);
|
||||
};
|
||||
|
||||
exports.transformFromAst = transformFromAst;
|
||||
|
||||
function transformFromAstSync(...args) {
|
||||
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformFromAstRunner.sync)(...args);
|
||||
}
|
||||
|
||||
function transformFromAstAsync(...args) {
|
||||
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformFromAstRunner.async)(...args);
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=transform-ast.js.map
|
||||
|
||||
5
tools/node_modules/eslint/node_modules/@babel/core/lib/transform-file-browser.js
generated
vendored
5
tools/node_modules/eslint/node_modules/@babel/core/lib/transform-file-browser.js
generated
vendored
@@ -11,20 +11,15 @@ const transformFile = function transformFile(filename, opts, callback) {
|
||||
if (typeof opts === "function") {
|
||||
callback = opts;
|
||||
}
|
||||
|
||||
callback(new Error("Transforming files is not supported in browsers"), null);
|
||||
};
|
||||
|
||||
exports.transformFile = transformFile;
|
||||
|
||||
function transformFileSync() {
|
||||
throw new Error("Transforming files is not supported in browsers");
|
||||
}
|
||||
|
||||
function transformFileAsync() {
|
||||
return Promise.reject(new Error("Transforming files is not supported in browsers"));
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=transform-file-browser.js.map
|
||||
|
||||
11
tools/node_modules/eslint/node_modules/@babel/core/lib/transform-file.js
generated
vendored
11
tools/node_modules/eslint/node_modules/@babel/core/lib/transform-file.js
generated
vendored
@@ -6,25 +6,17 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.transformFile = transformFile;
|
||||
exports.transformFileAsync = transformFileAsync;
|
||||
exports.transformFileSync = transformFileSync;
|
||||
|
||||
function _gensync() {
|
||||
const data = require("gensync");
|
||||
|
||||
_gensync = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _config = require("./config");
|
||||
|
||||
var _transformation = require("./transformation");
|
||||
|
||||
var fs = require("./gensync-utils/fs");
|
||||
|
||||
({});
|
||||
|
||||
const transformFileRunner = _gensync()(function* (filename, opts) {
|
||||
const options = Object.assign({}, opts, {
|
||||
filename
|
||||
@@ -38,15 +30,12 @@ const transformFileRunner = _gensync()(function* (filename, opts) {
|
||||
function transformFile(...args) {
|
||||
return transformFileRunner.errback(...args);
|
||||
}
|
||||
|
||||
function transformFileSync(...args) {
|
||||
return transformFileRunner.sync(...args);
|
||||
}
|
||||
|
||||
function transformFileAsync(...args) {
|
||||
return transformFileRunner.async(...args);
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=transform-file.js.map
|
||||
|
||||
15
tools/node_modules/eslint/node_modules/@babel/core/lib/transform.js
generated
vendored
15
tools/node_modules/eslint/node_modules/@babel/core/lib/transform.js
generated
vendored
@@ -6,33 +6,24 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.transform = void 0;
|
||||
exports.transformAsync = transformAsync;
|
||||
exports.transformSync = transformSync;
|
||||
|
||||
function _gensync() {
|
||||
const data = require("gensync");
|
||||
|
||||
_gensync = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _config = require("./config");
|
||||
|
||||
var _transformation = require("./transformation");
|
||||
|
||||
var _rewriteStackTrace = require("./errors/rewrite-stack-trace");
|
||||
|
||||
const transformRunner = _gensync()(function* transform(code, opts) {
|
||||
const config = yield* (0, _config.default)(opts);
|
||||
if (config === null) return null;
|
||||
return yield* (0, _transformation.run)(config, code);
|
||||
});
|
||||
|
||||
const transform = function transform(code, optsOrCallback, maybeCallback) {
|
||||
let opts;
|
||||
let callback;
|
||||
|
||||
if (typeof optsOrCallback === "function") {
|
||||
callback = optsOrCallback;
|
||||
opts = undefined;
|
||||
@@ -40,26 +31,20 @@ const transform = function transform(code, optsOrCallback, maybeCallback) {
|
||||
opts = optsOrCallback;
|
||||
callback = maybeCallback;
|
||||
}
|
||||
|
||||
if (callback === undefined) {
|
||||
{
|
||||
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.sync)(code, opts);
|
||||
}
|
||||
}
|
||||
|
||||
(0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.errback)(code, opts, callback);
|
||||
};
|
||||
|
||||
exports.transform = transform;
|
||||
|
||||
function transformSync(...args) {
|
||||
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.sync)(...args);
|
||||
}
|
||||
|
||||
function transformAsync(...args) {
|
||||
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.async)(...args);
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=transform.js.map
|
||||
|
||||
@@ -4,63 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = loadBlockHoistPlugin;
|
||||
|
||||
function _traverse() {
|
||||
const data = require("@babel/traverse");
|
||||
|
||||
_traverse = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _plugin = require("../config/plugin");
|
||||
|
||||
let LOADED_PLUGIN;
|
||||
|
||||
function loadBlockHoistPlugin() {
|
||||
if (!LOADED_PLUGIN) {
|
||||
LOADED_PLUGIN = new _plugin.default(Object.assign({}, blockHoistPlugin, {
|
||||
visitor: _traverse().default.explode(blockHoistPlugin.visitor)
|
||||
}), {});
|
||||
}
|
||||
|
||||
return LOADED_PLUGIN;
|
||||
}
|
||||
|
||||
function priority(bodyNode) {
|
||||
const priority = bodyNode == null ? void 0 : bodyNode._blockHoist;
|
||||
if (priority == null) return 1;
|
||||
if (priority === true) return 2;
|
||||
return priority;
|
||||
}
|
||||
|
||||
function stableSort(body) {
|
||||
const buckets = Object.create(null);
|
||||
|
||||
for (let i = 0; i < body.length; i++) {
|
||||
const n = body[i];
|
||||
const p = priority(n);
|
||||
const bucket = buckets[p] || (buckets[p] = []);
|
||||
bucket.push(n);
|
||||
}
|
||||
|
||||
const keys = Object.keys(buckets).map(k => +k).sort((a, b) => b - a);
|
||||
let index = 0;
|
||||
|
||||
for (const key of keys) {
|
||||
const bucket = buckets[key];
|
||||
|
||||
for (const n of bucket) {
|
||||
body[index++] = n;
|
||||
}
|
||||
}
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
const blockHoistPlugin = {
|
||||
|
||||
name: "internal.blockHoist",
|
||||
visitor: {
|
||||
Block: {
|
||||
@@ -70,28 +24,60 @@ const blockHoistPlugin = {
|
||||
const {
|
||||
body
|
||||
} = node;
|
||||
|
||||
let max = Math.pow(2, 30) - 1;
|
||||
let hasChange = false;
|
||||
|
||||
for (let i = 0; i < body.length; i++) {
|
||||
const n = body[i];
|
||||
const p = priority(n);
|
||||
|
||||
if (p > max) {
|
||||
hasChange = true;
|
||||
break;
|
||||
}
|
||||
|
||||
max = p;
|
||||
}
|
||||
|
||||
if (!hasChange) return;
|
||||
|
||||
node.body = stableSort(body.slice());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
function loadBlockHoistPlugin() {
|
||||
if (!LOADED_PLUGIN) {
|
||||
LOADED_PLUGIN = new _plugin.default(Object.assign({}, blockHoistPlugin, {
|
||||
visitor: _traverse().default.explode(blockHoistPlugin.visitor)
|
||||
}), {});
|
||||
}
|
||||
return LOADED_PLUGIN;
|
||||
}
|
||||
function priority(bodyNode) {
|
||||
const priority = bodyNode == null ? void 0 : bodyNode._blockHoist;
|
||||
if (priority == null) return 1;
|
||||
if (priority === true) return 2;
|
||||
return priority;
|
||||
}
|
||||
function stableSort(body) {
|
||||
const buckets = Object.create(null);
|
||||
|
||||
for (let i = 0; i < body.length; i++) {
|
||||
const n = body[i];
|
||||
const p = priority(n);
|
||||
|
||||
const bucket = buckets[p] || (buckets[p] = []);
|
||||
bucket.push(n);
|
||||
}
|
||||
|
||||
const keys = Object.keys(buckets).map(k => +k).sort((a, b) => b - a);
|
||||
let index = 0;
|
||||
for (const key of keys) {
|
||||
const bucket = buckets[key];
|
||||
for (const n of bucket) {
|
||||
body[index++] = n;
|
||||
}
|
||||
}
|
||||
return body;
|
||||
}
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=block-hoist-plugin.js.map
|
||||
|
||||
44
tools/node_modules/eslint/node_modules/@babel/core/lib/transformation/file/file.js
generated
vendored
44
tools/node_modules/eslint/node_modules/@babel/core/lib/transformation/file/file.js
generated
vendored
@@ -4,84 +4,61 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function helpers() {
|
||||
const data = require("@babel/helpers");
|
||||
|
||||
helpers = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _traverse() {
|
||||
const data = require("@babel/traverse");
|
||||
|
||||
_traverse = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _codeFrame() {
|
||||
const data = require("@babel/code-frame");
|
||||
|
||||
_codeFrame = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _t() {
|
||||
const data = require("@babel/types");
|
||||
|
||||
_t = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _helperModuleTransforms() {
|
||||
const data = require("@babel/helper-module-transforms");
|
||||
|
||||
_helperModuleTransforms = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _semver() {
|
||||
const data = require("semver");
|
||||
|
||||
_semver = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
const {
|
||||
cloneNode,
|
||||
interpreterDirective
|
||||
} = _t();
|
||||
|
||||
const errorVisitor = {
|
||||
enter(path, state) {
|
||||
const loc = path.node.loc;
|
||||
|
||||
if (loc) {
|
||||
state.loc = loc;
|
||||
path.stop();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class File {
|
||||
constructor(options, {
|
||||
code,
|
||||
@@ -124,7 +101,6 @@ class File {
|
||||
} = this.path.node;
|
||||
return interpreter ? interpreter.value : "";
|
||||
}
|
||||
|
||||
set shebang(value) {
|
||||
if (value) {
|
||||
this.path.get("interpreter").replaceWith(interpreterDirective(value));
|
||||
@@ -132,51 +108,42 @@ class File {
|
||||
this.path.get("interpreter").remove();
|
||||
}
|
||||
}
|
||||
|
||||
set(key, val) {
|
||||
if (key === "helpersNamespace") {
|
||||
throw new Error("Babel 7.0.0-beta.56 has dropped support for the 'helpersNamespace' utility." + "If you are using @babel/plugin-external-helpers you will need to use a newer " + "version than the one you currently have installed. " + "If you have your own implementation, you'll want to explore using 'helperGenerator' " + "alongside 'file.availableHelper()'.");
|
||||
}
|
||||
|
||||
this._map.set(key, val);
|
||||
}
|
||||
|
||||
get(key) {
|
||||
return this._map.get(key);
|
||||
}
|
||||
|
||||
has(key) {
|
||||
return this._map.has(key);
|
||||
}
|
||||
|
||||
getModuleName() {
|
||||
return (0, _helperModuleTransforms().getModuleName)(this.opts, this.opts);
|
||||
}
|
||||
|
||||
addImport() {
|
||||
throw new Error("This API has been removed. If you're looking for this " + "functionality in Babel 7, you should import the " + "'@babel/helper-module-imports' module and use the functions exposed " + " from that module, such as 'addNamed' or 'addDefault'.");
|
||||
}
|
||||
|
||||
availableHelper(name, versionRange) {
|
||||
let minVersion;
|
||||
|
||||
try {
|
||||
minVersion = helpers().minVersion(name);
|
||||
} catch (err) {
|
||||
if (err.code !== "BABEL_HELPER_UNKNOWN") throw err;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof versionRange !== "string") return true;
|
||||
|
||||
if (_semver().valid(versionRange)) versionRange = `^${versionRange}`;
|
||||
return !_semver().intersects(`<${minVersion}`, versionRange) && !_semver().intersects(`>=8.0.0`, versionRange);
|
||||
}
|
||||
|
||||
addHelper(name) {
|
||||
const declar = this.declarations[name];
|
||||
if (declar) return cloneNode(declar);
|
||||
const generator = this.get("helperGenerator");
|
||||
|
||||
if (generator) {
|
||||
const res = generator(name);
|
||||
if (res) return res;
|
||||
@@ -185,11 +152,9 @@ class File {
|
||||
helpers().ensure(name, File);
|
||||
const uid = this.declarations[name] = this.scope.generateUidIdentifier(name);
|
||||
const dependencies = {};
|
||||
|
||||
for (const dep of helpers().getDependencies(name)) {
|
||||
dependencies[dep] = this.addHelper(dep);
|
||||
}
|
||||
|
||||
const {
|
||||
nodes,
|
||||
globals
|
||||
@@ -209,14 +174,11 @@ class File {
|
||||
});
|
||||
return uid;
|
||||
}
|
||||
|
||||
addTemplateObject() {
|
||||
throw new Error("This function has been moved into the template literal transform itself.");
|
||||
}
|
||||
|
||||
buildCodeFrameError(node, msg, _Error = SyntaxError) {
|
||||
let loc = node && (node.loc || node._loc);
|
||||
|
||||
if (!loc && node) {
|
||||
const state = {
|
||||
loc: null
|
||||
@@ -227,7 +189,6 @@ class File {
|
||||
if (loc) txt += " Location has been estimated.";
|
||||
msg += ` (${txt})`;
|
||||
}
|
||||
|
||||
if (loc) {
|
||||
const {
|
||||
highlightCode = true
|
||||
@@ -245,12 +206,9 @@ class File {
|
||||
highlightCode
|
||||
});
|
||||
}
|
||||
|
||||
return new _Error(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = File;
|
||||
0 && 0;
|
||||
|
||||
|
||||
18
tools/node_modules/eslint/node_modules/@babel/core/lib/transformation/file/generate.js
generated
vendored
18
tools/node_modules/eslint/node_modules/@babel/core/lib/transformation/file/generate.js
generated
vendored
@@ -4,29 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = generateCode;
|
||||
|
||||
function _convertSourceMap() {
|
||||
const data = require("convert-source-map");
|
||||
|
||||
_convertSourceMap = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _generator() {
|
||||
const data = require("@babel/generator");
|
||||
|
||||
_generator = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _mergeMap = require("./merge-map");
|
||||
|
||||
function generateCode(pluginPasses, file) {
|
||||
const {
|
||||
opts,
|
||||
@@ -38,27 +30,22 @@ function generateCode(pluginPasses, file) {
|
||||
generatorOpts
|
||||
} = opts;
|
||||
const results = [];
|
||||
|
||||
for (const plugins of pluginPasses) {
|
||||
for (const plugin of plugins) {
|
||||
const {
|
||||
generatorOverride
|
||||
} = plugin;
|
||||
|
||||
if (generatorOverride) {
|
||||
const result = generatorOverride(ast, generatorOpts, code, _generator().default);
|
||||
if (result !== undefined) results.push(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let result;
|
||||
|
||||
if (results.length === 0) {
|
||||
result = (0, _generator().default)(ast, generatorOpts, code);
|
||||
} else if (results.length === 1) {
|
||||
result = results[0];
|
||||
|
||||
if (typeof result.then === "function") {
|
||||
throw new Error(`You appear to be using an async codegen plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, ` + `you may need to upgrade your @babel/core version.`);
|
||||
}
|
||||
@@ -70,7 +57,6 @@ function generateCode(pluginPasses, file) {
|
||||
code: outputCode,
|
||||
decodedMap: outputMap = result.map
|
||||
} = result;
|
||||
|
||||
if (outputMap) {
|
||||
if (inputMap) {
|
||||
outputMap = (0, _mergeMap.default)(inputMap.toObject(), outputMap, generatorOpts.sourceFileName);
|
||||
@@ -78,21 +64,17 @@ function generateCode(pluginPasses, file) {
|
||||
outputMap = result.map;
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.sourceMaps === "inline" || opts.sourceMaps === "both") {
|
||||
outputCode += "\n" + _convertSourceMap().fromObject(outputMap).toComment();
|
||||
}
|
||||
|
||||
if (opts.sourceMaps === "inline") {
|
||||
outputMap = null;
|
||||
}
|
||||
|
||||
return {
|
||||
outputCode,
|
||||
outputMap
|
||||
};
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=generate.js.map
|
||||
|
||||
10
tools/node_modules/eslint/node_modules/@babel/core/lib/transformation/file/merge-map.js
generated
vendored
10
tools/node_modules/eslint/node_modules/@babel/core/lib/transformation/file/merge-map.js
generated
vendored
@@ -4,44 +4,36 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = mergeSourceMap;
|
||||
|
||||
function _remapping() {
|
||||
const data = require("@ampproject/remapping");
|
||||
|
||||
_remapping = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function mergeSourceMap(inputMap, map, sourceFileName) {
|
||||
const source = sourceFileName.replace(/\\/g, "/");
|
||||
let found = false;
|
||||
|
||||
let found = false;
|
||||
const result = _remapping()(rootless(map), (s, ctx) => {
|
||||
if (s === source && !found) {
|
||||
found = true;
|
||||
ctx.source = "";
|
||||
return rootless(inputMap);
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
if (typeof inputMap.sourceRoot === "string") {
|
||||
result.sourceRoot = inputMap.sourceRoot;
|
||||
}
|
||||
|
||||
return Object.assign({}, result);
|
||||
}
|
||||
|
||||
function rootless(map) {
|
||||
return Object.assign({}, map, {
|
||||
sourceRoot: null
|
||||
});
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=merge-map.js.map
|
||||
|
||||
33
tools/node_modules/eslint/node_modules/@babel/core/lib/transformation/index.js
generated
vendored
33
tools/node_modules/eslint/node_modules/@babel/core/lib/transformation/index.js
generated
vendored
@@ -4,49 +4,33 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.run = run;
|
||||
|
||||
function _traverse() {
|
||||
const data = require("@babel/traverse");
|
||||
|
||||
_traverse = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _pluginPass = require("./plugin-pass");
|
||||
|
||||
var _blockHoistPlugin = require("./block-hoist-plugin");
|
||||
|
||||
var _normalizeOpts = require("./normalize-opts");
|
||||
|
||||
var _normalizeFile = require("./normalize-file");
|
||||
|
||||
var _generate = require("./file/generate");
|
||||
|
||||
var _deepArray = require("../config/helpers/deep-array");
|
||||
|
||||
function* run(config, code, ast) {
|
||||
const file = yield* (0, _normalizeFile.default)(config.passes, (0, _normalizeOpts.default)(config), code, ast);
|
||||
const opts = file.opts;
|
||||
|
||||
try {
|
||||
yield* transformFile(file, config.passes);
|
||||
} catch (e) {
|
||||
var _opts$filename;
|
||||
|
||||
e.message = `${(_opts$filename = opts.filename) != null ? _opts$filename : "unknown file"}: ${e.message}`;
|
||||
|
||||
if (!e.code) {
|
||||
e.code = "BABEL_TRANSFORM_ERROR";
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
let outputCode, outputMap;
|
||||
|
||||
try {
|
||||
if (opts.code !== false) {
|
||||
({
|
||||
@@ -56,16 +40,12 @@ function* run(config, code, ast) {
|
||||
}
|
||||
} catch (e) {
|
||||
var _opts$filename2;
|
||||
|
||||
e.message = `${(_opts$filename2 = opts.filename) != null ? _opts$filename2 : "unknown file"}: ${e.message}`;
|
||||
|
||||
if (!e.code) {
|
||||
e.code = "BABEL_GENERATE_ERROR";
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
return {
|
||||
metadata: file.metadata,
|
||||
options: opts,
|
||||
@@ -76,27 +56,23 @@ function* run(config, code, ast) {
|
||||
externalDependencies: (0, _deepArray.flattenToSet)(config.externalDependencies)
|
||||
};
|
||||
}
|
||||
|
||||
function* transformFile(file, pluginPasses) {
|
||||
for (const pluginPairs of pluginPasses) {
|
||||
const passPairs = [];
|
||||
const passes = [];
|
||||
const visitors = [];
|
||||
|
||||
for (const plugin of pluginPairs.concat([(0, _blockHoistPlugin.default)()])) {
|
||||
const pass = new _pluginPass.default(file, plugin.key, plugin.options);
|
||||
passPairs.push([plugin, pass]);
|
||||
passes.push(pass);
|
||||
visitors.push(plugin.visitor);
|
||||
}
|
||||
|
||||
for (const [plugin, pass] of passPairs) {
|
||||
const fn = plugin.pre;
|
||||
|
||||
if (fn) {
|
||||
const result = fn.call(pass, file);
|
||||
yield* [];
|
||||
|
||||
yield* [];
|
||||
if (isThenable(result)) {
|
||||
throw new Error(`You appear to be using an plugin with an async .pre, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`);
|
||||
}
|
||||
@@ -104,16 +80,13 @@ function* transformFile(file, pluginPasses) {
|
||||
}
|
||||
|
||||
const visitor = _traverse().default.visitors.merge(visitors, passes, file.opts.wrapPluginVisitorMethod);
|
||||
|
||||
(0, _traverse().default)(file.ast, visitor, file.scope);
|
||||
|
||||
for (const [plugin, pass] of passPairs) {
|
||||
const fn = plugin.post;
|
||||
|
||||
if (fn) {
|
||||
const result = fn.call(pass, file);
|
||||
yield* [];
|
||||
|
||||
yield* [];
|
||||
if (isThenable(result)) {
|
||||
throw new Error(`You appear to be using an plugin with an async .post, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`);
|
||||
}
|
||||
@@ -121,11 +94,9 @@ function* transformFile(file, pluginPasses) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isThenable(val) {
|
||||
return !!val && (typeof val === "object" || typeof val === "function") && !!val.then && typeof val.then === "function";
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
45
tools/node_modules/eslint/node_modules/@babel/core/lib/transformation/normalize-file.js
generated
vendored
45
tools/node_modules/eslint/node_modules/@babel/core/lib/transformation/normalize-file.js
generated
vendored
@@ -4,99 +4,74 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = normalizeFile;
|
||||
|
||||
function _fs() {
|
||||
const data = require("fs");
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _debug() {
|
||||
const data = require("debug");
|
||||
|
||||
_debug = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _t() {
|
||||
const data = require("@babel/types");
|
||||
|
||||
_t = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _convertSourceMap() {
|
||||
const data = require("convert-source-map");
|
||||
|
||||
_convertSourceMap = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _file = require("./file/file");
|
||||
|
||||
var _parser = require("../parser");
|
||||
|
||||
var _cloneDeep = require("./util/clone-deep");
|
||||
|
||||
const {
|
||||
file,
|
||||
traverseFast
|
||||
} = _t();
|
||||
|
||||
const debug = _debug()("babel:transform:file");
|
||||
|
||||
const LARGE_INPUT_SOURCEMAP_THRESHOLD = 3000000;
|
||||
|
||||
const INLINE_SOURCEMAP_REGEX = /^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/;
|
||||
const EXTERNAL_SOURCEMAP_REGEX = /^[@#][ \t]+sourceMappingURL=([^\s'"`]+)[ \t]*$/;
|
||||
function* normalizeFile(pluginPasses, options, code, ast) {
|
||||
code = `${code || ""}`;
|
||||
|
||||
if (ast) {
|
||||
if (ast.type === "Program") {
|
||||
ast = file(ast, [], []);
|
||||
} else if (ast.type !== "File") {
|
||||
throw new Error("AST root must be a Program or File node");
|
||||
}
|
||||
|
||||
if (options.cloneInputAst) {
|
||||
ast = (0, _cloneDeep.default)(ast);
|
||||
}
|
||||
} else {
|
||||
ast = yield* (0, _parser.default)(pluginPasses, options, code);
|
||||
}
|
||||
|
||||
let inputMap = null;
|
||||
|
||||
if (options.inputSourceMap !== false) {
|
||||
if (typeof options.inputSourceMap === "object") {
|
||||
inputMap = _convertSourceMap().fromObject(options.inputSourceMap);
|
||||
}
|
||||
|
||||
if (!inputMap) {
|
||||
const lastComment = extractComments(INLINE_SOURCEMAP_REGEX, ast);
|
||||
|
||||
if (lastComment) {
|
||||
try {
|
||||
inputMap = _convertSourceMap().fromComment(lastComment);
|
||||
@@ -105,20 +80,17 @@ function* normalizeFile(pluginPasses, options, code, ast) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!inputMap) {
|
||||
const lastComment = extractComments(EXTERNAL_SOURCEMAP_REGEX, ast);
|
||||
|
||||
if (typeof options.filename === "string" && lastComment) {
|
||||
try {
|
||||
const match = EXTERNAL_SOURCEMAP_REGEX.exec(lastComment);
|
||||
|
||||
const inputMapContent = _fs().readFileSync(_path().resolve(_path().dirname(options.filename), match[1]));
|
||||
|
||||
if (inputMapContent.length > LARGE_INPUT_SOURCEMAP_THRESHOLD) {
|
||||
debug("skip merging input map > 1 MB");
|
||||
} else {
|
||||
inputMap = _convertSourceMap().fromJSON(inputMapContent);
|
||||
inputMap = _convertSourceMap().fromJSON(
|
||||
inputMapContent);
|
||||
}
|
||||
} catch (err) {
|
||||
debug("discarding unknown file input sourcemap", err);
|
||||
@@ -128,17 +100,12 @@ function* normalizeFile(pluginPasses, options, code, ast) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new _file.default(options, {
|
||||
code,
|
||||
ast: ast,
|
||||
inputMap
|
||||
});
|
||||
}
|
||||
|
||||
const INLINE_SOURCEMAP_REGEX = /^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/;
|
||||
const EXTERNAL_SOURCEMAP_REGEX = /^[@#][ \t]+sourceMappingURL=([^\s'"`]+)[ \t]*$/;
|
||||
|
||||
function extractCommentsFromList(regex, comments, lastComment) {
|
||||
if (comments) {
|
||||
comments = comments.filter(({
|
||||
@@ -148,14 +115,11 @@ function extractCommentsFromList(regex, comments, lastComment) {
|
||||
lastComment = value;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
return [comments, lastComment];
|
||||
}
|
||||
|
||||
function extractComments(regex, ast) {
|
||||
let lastComment = null;
|
||||
traverseFast(ast, node => {
|
||||
@@ -165,7 +129,6 @@ function extractComments(regex, ast) {
|
||||
});
|
||||
return lastComment;
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=normalize-file.js.map
|
||||
|
||||
@@ -4,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = normalizeOptions;
|
||||
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function normalizeOptions(config) {
|
||||
const {
|
||||
filename,
|
||||
@@ -49,7 +45,6 @@ function normalizeOptions(config) {
|
||||
sourceFileName
|
||||
}, opts.generatorOpts)
|
||||
});
|
||||
|
||||
for (const plugins of config.passes) {
|
||||
for (const plugin of plugins) {
|
||||
if (plugin.manipulateOptions) {
|
||||
@@ -57,10 +52,8 @@ function normalizeOptions(config) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=normalize-opts.js.map
|
||||
|
||||
10
tools/node_modules/eslint/node_modules/@babel/core/lib/transformation/plugin-pass.js
generated
vendored
10
tools/node_modules/eslint/node_modules/@babel/core/lib/transformation/plugin-pass.js
generated
vendored
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
class PluginPass {
|
||||
|
||||
constructor(file, key, options) {
|
||||
this._map = new Map();
|
||||
this.key = void 0;
|
||||
@@ -19,33 +19,25 @@ class PluginPass {
|
||||
this.cwd = file.opts.cwd;
|
||||
this.filename = file.opts.filename;
|
||||
}
|
||||
|
||||
set(key, val) {
|
||||
this._map.set(key, val);
|
||||
}
|
||||
|
||||
get(key) {
|
||||
return this._map.get(key);
|
||||
}
|
||||
|
||||
availableHelper(name, versionRange) {
|
||||
return this.file.availableHelper(name, versionRange);
|
||||
}
|
||||
|
||||
addHelper(name) {
|
||||
return this.file.addHelper(name);
|
||||
}
|
||||
|
||||
addImport() {
|
||||
return this.file.addImport();
|
||||
}
|
||||
|
||||
buildCodeFrameError(node, msg, _Error) {
|
||||
return this.file.buildCodeFrameError(node, msg, _Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = PluginPass;
|
||||
{
|
||||
PluginPass.prototype.getModuleName = function getModuleName() {
|
||||
|
||||
@@ -4,40 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _default;
|
||||
|
||||
function deepClone(value, cache) {
|
||||
if (value !== null) {
|
||||
if (cache.has(value)) return cache.get(value);
|
||||
let cloned;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
cloned = new Array(value.length);
|
||||
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
cloned[i] = typeof value[i] !== "object" ? value[i] : deepClone(value[i], cache);
|
||||
}
|
||||
} else {
|
||||
cloned = {};
|
||||
const keys = Object.keys(value);
|
||||
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
cloned[key] = typeof value[key] !== "object" ? value[key] : deepClone(value[key], cache);
|
||||
}
|
||||
}
|
||||
|
||||
cache.set(value, cloned);
|
||||
return cloned;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function _default(value) {
|
||||
if (typeof value !== "object") return value;
|
||||
return deepClone(value, new Map());
|
||||
}
|
||||
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=clone-deep.js.map
|
||||
|
||||
702
tools/node_modules/eslint/node_modules/@babel/core/lib/vendor/import-meta-resolve.js
generated
vendored
702
tools/node_modules/eslint/node_modules/@babel/core/lib/vendor/import-meta-resolve.js
generated
vendored
File diff suppressed because it is too large
Load Diff
18
tools/node_modules/eslint/node_modules/@babel/core/package.json
generated
vendored
18
tools/node_modules/eslint/node_modules/@babel/core/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/core",
|
||||
"version": "7.19.6",
|
||||
"version": "7.20.2",
|
||||
"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.6",
|
||||
"@babel/helper-compilation-targets": "^7.19.3",
|
||||
"@babel/helper-module-transforms": "^7.19.6",
|
||||
"@babel/helpers": "^7.19.4",
|
||||
"@babel/parser": "^7.19.6",
|
||||
"@babel/generator": "^7.20.2",
|
||||
"@babel/helper-compilation-targets": "^7.20.0",
|
||||
"@babel/helper-module-transforms": "^7.20.2",
|
||||
"@babel/helpers": "^7.20.1",
|
||||
"@babel/parser": "^7.20.2",
|
||||
"@babel/template": "^7.18.10",
|
||||
"@babel/traverse": "^7.19.6",
|
||||
"@babel/types": "^7.19.4",
|
||||
"@babel/traverse": "^7.20.1",
|
||||
"@babel/types": "^7.20.2",
|
||||
"convert-source-map": "^1.7.0",
|
||||
"debug": "^4.1.0",
|
||||
"gensync": "^1.0.0-beta.2",
|
||||
@@ -67,7 +67,7 @@
|
||||
"@babel/plugin-syntax-flow": "^7.18.6",
|
||||
"@babel/plugin-transform-flow-strip-types": "^7.19.0",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.19.6",
|
||||
"@babel/preset-env": "^7.19.4",
|
||||
"@babel/preset-env": "^7.20.2",
|
||||
"@jridgewell/trace-mapping": "^0.3.8",
|
||||
"@types/convert-source-map": "^1.5.1",
|
||||
"@types/debug": "^4.1.0",
|
||||
|
||||
62
tools/node_modules/eslint/node_modules/@babel/generator/lib/buffer.js
generated
vendored
62
tools/node_modules/eslint/node_modules/@babel/generator/lib/buffer.js
generated
vendored
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
class Buffer {
|
||||
constructor(map) {
|
||||
this._map = null;
|
||||
@@ -25,13 +24,10 @@ class Buffer {
|
||||
filename: undefined
|
||||
};
|
||||
this._map = map;
|
||||
|
||||
this._allocQueue();
|
||||
}
|
||||
|
||||
_allocQueue() {
|
||||
const queue = this._queue;
|
||||
|
||||
for (let i = 0; i < 16; i++) {
|
||||
queue.push({
|
||||
char: 0,
|
||||
@@ -43,14 +39,11 @@ class Buffer {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_pushQueue(char, repeat, line, column, identifierName, filename) {
|
||||
const cursor = this._queueCursor;
|
||||
|
||||
if (cursor === this._queue.length) {
|
||||
this._allocQueue();
|
||||
}
|
||||
|
||||
const item = this._queue[cursor];
|
||||
item.char = char;
|
||||
item.repeat = repeat;
|
||||
@@ -60,62 +53,51 @@ class Buffer {
|
||||
item.filename = filename;
|
||||
this._queueCursor++;
|
||||
}
|
||||
|
||||
_popQueue() {
|
||||
if (this._queueCursor === 0) {
|
||||
throw new Error("Cannot pop from empty queue");
|
||||
}
|
||||
|
||||
return this._queue[--this._queueCursor];
|
||||
}
|
||||
|
||||
get() {
|
||||
this._flush();
|
||||
|
||||
const map = this._map;
|
||||
const result = {
|
||||
code: (this._buf + this._str).trimRight(),
|
||||
decodedMap: map == null ? void 0 : map.getDecoded(),
|
||||
|
||||
get map() {
|
||||
const resultMap = map ? map.get() : null;
|
||||
result.map = resultMap;
|
||||
return resultMap;
|
||||
},
|
||||
|
||||
set map(value) {
|
||||
Object.defineProperty(result, "map", {
|
||||
value,
|
||||
writable: true
|
||||
});
|
||||
},
|
||||
|
||||
get rawMappings() {
|
||||
const mappings = map == null ? void 0 : map.getRawMappings();
|
||||
result.rawMappings = mappings;
|
||||
return mappings;
|
||||
},
|
||||
|
||||
set rawMappings(value) {
|
||||
Object.defineProperty(result, "rawMappings", {
|
||||
value,
|
||||
writable: true
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
append(str, maybeNewline) {
|
||||
this._flush();
|
||||
|
||||
this._append(str, this._sourcePosition, maybeNewline);
|
||||
}
|
||||
|
||||
appendChar(char) {
|
||||
this._flush();
|
||||
|
||||
this._appendChar(char, 1, this._sourcePosition);
|
||||
}
|
||||
|
||||
@@ -123,56 +105,43 @@ class Buffer {
|
||||
if (char === 10) {
|
||||
while (this._queueCursor !== 0) {
|
||||
const char = this._queue[this._queueCursor - 1].char;
|
||||
|
||||
if (char !== 32 && char !== 9) {
|
||||
break;
|
||||
}
|
||||
|
||||
this._queueCursor--;
|
||||
}
|
||||
}
|
||||
|
||||
const sourcePosition = this._sourcePosition;
|
||||
|
||||
this._pushQueue(char, 1, sourcePosition.line, sourcePosition.column, sourcePosition.identifierName, sourcePosition.filename);
|
||||
}
|
||||
|
||||
queueIndentation(char, repeat) {
|
||||
this._pushQueue(char, repeat, undefined, undefined, undefined, undefined);
|
||||
}
|
||||
|
||||
_flush() {
|
||||
const queueCursor = this._queueCursor;
|
||||
const queue = this._queue;
|
||||
|
||||
for (let i = 0; i < queueCursor; i++) {
|
||||
const item = queue[i];
|
||||
|
||||
this._appendChar(item.char, item.repeat, item);
|
||||
}
|
||||
|
||||
this._queueCursor = 0;
|
||||
}
|
||||
|
||||
_appendChar(char, repeat, sourcePos) {
|
||||
this._last = char;
|
||||
this._str += repeat > 1 ? String.fromCharCode(char).repeat(repeat) : String.fromCharCode(char);
|
||||
|
||||
if (char !== 10) {
|
||||
this._mark(sourcePos.line, sourcePos.column, sourcePos.identifierName, sourcePos.filename);
|
||||
|
||||
this._position.column += repeat;
|
||||
} else {
|
||||
this._position.line++;
|
||||
this._position.column = 0;
|
||||
}
|
||||
}
|
||||
|
||||
_append(str, sourcePos, maybeNewline) {
|
||||
const len = str.length;
|
||||
const position = this._position;
|
||||
this._last = str.charCodeAt(len - 1);
|
||||
|
||||
if (++this._appendCount > 4096) {
|
||||
+this._str;
|
||||
this._buf += this._str;
|
||||
@@ -181,18 +150,17 @@ class Buffer {
|
||||
} else {
|
||||
this._str += str;
|
||||
}
|
||||
|
||||
if (!maybeNewline && !this._map) {
|
||||
position.column += len;
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
column,
|
||||
identifierName,
|
||||
filename
|
||||
} = sourcePos;
|
||||
let line = sourcePos.line;
|
||||
|
||||
let i = str.indexOf("\n");
|
||||
let last = 0;
|
||||
|
||||
@@ -208,35 +176,26 @@ class Buffer {
|
||||
if (last < len) {
|
||||
this._mark(++line, 0, identifierName, filename);
|
||||
}
|
||||
|
||||
i = str.indexOf("\n", last);
|
||||
}
|
||||
|
||||
position.column += len - last;
|
||||
}
|
||||
|
||||
_mark(line, column, identifierName, filename) {
|
||||
var _this$_map;
|
||||
|
||||
(_this$_map = this._map) == null ? void 0 : _this$_map.mark(this._position, line, column, identifierName, filename);
|
||||
}
|
||||
|
||||
removeTrailingNewline() {
|
||||
const queueCursor = this._queueCursor;
|
||||
|
||||
if (queueCursor !== 0 && this._queue[queueCursor - 1].char === 10) {
|
||||
this._queueCursor--;
|
||||
}
|
||||
}
|
||||
|
||||
removeLastSemicolon() {
|
||||
const queueCursor = this._queueCursor;
|
||||
|
||||
if (queueCursor !== 0 && this._queue[queueCursor - 1].char === 59) {
|
||||
this._queueCursor--;
|
||||
}
|
||||
}
|
||||
|
||||
getLastChar() {
|
||||
const queueCursor = this._queueCursor;
|
||||
return queueCursor !== 0 ? this._queue[queueCursor - 1].char : this._last;
|
||||
@@ -246,26 +205,21 @@ class Buffer {
|
||||
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;
|
||||
|
||||
if (queueCursor !== 0) {
|
||||
const lastCp = queue[queueCursor - 1].char;
|
||||
if (lastCp !== 10) return;
|
||||
|
||||
if (queueCursor > 1) {
|
||||
return queue[queueCursor - 2].char;
|
||||
} else {
|
||||
@@ -290,10 +244,8 @@ class Buffer {
|
||||
|
||||
this._normalizePosition(prop, loc, 0, 0);
|
||||
}
|
||||
|
||||
sourceWithOffset(prop, loc, lineOffset, columnOffset) {
|
||||
if (!this._map) return;
|
||||
|
||||
this._normalizePosition(prop, loc, lineOffset, columnOffset);
|
||||
}
|
||||
|
||||
@@ -302,53 +254,41 @@ class Buffer {
|
||||
this.source(prop, loc);
|
||||
cb();
|
||||
}
|
||||
|
||||
_normalizePosition(prop, loc, lineOffset, columnOffset) {
|
||||
const pos = loc[prop];
|
||||
const target = this._sourcePosition;
|
||||
target.identifierName = prop === "start" && loc.identifierName || undefined;
|
||||
|
||||
if (pos) {
|
||||
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 < queueCursor; i++) {
|
||||
const item = queue[i];
|
||||
|
||||
if (item.char === 10) {
|
||||
lastIndex = len;
|
||||
}
|
||||
|
||||
len += item.repeat;
|
||||
}
|
||||
|
||||
return lastIndex === -1 ? this._position.column + len : len - 1 - lastIndex;
|
||||
}
|
||||
|
||||
getCurrentLine() {
|
||||
let count = 0;
|
||||
const queue = this._queue;
|
||||
|
||||
for (let i = 0; i < this._queueCursor; i++) {
|
||||
if (queue[i].char === 10) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return this._position.line + count;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = Buffer;
|
||||
|
||||
//# sourceMappingURL=buffer.js.map
|
||||
|
||||
25
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/base.js
generated
vendored
25
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/base.js
generated
vendored
@@ -10,65 +10,50 @@ exports.File = File;
|
||||
exports.InterpreterDirective = InterpreterDirective;
|
||||
exports.Placeholder = Placeholder;
|
||||
exports.Program = Program;
|
||||
|
||||
function File(node) {
|
||||
if (node.program) {
|
||||
this.print(node.program.interpreter, node);
|
||||
}
|
||||
|
||||
this.print(node.program, node);
|
||||
}
|
||||
|
||||
function Program(node) {
|
||||
var _node$directives;
|
||||
|
||||
this.printInnerComments(node, false);
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.printInnerComments();
|
||||
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$directives2;
|
||||
|
||||
this.tokenChar(123);
|
||||
this.printInnerComments(node);
|
||||
const directivesLen = (_node$directives2 = node.directives) == null ? void 0 : _node$directives2.length;
|
||||
|
||||
if (directivesLen) {
|
||||
var _node$directives$trai2;
|
||||
|
||||
const newline = node.body.length ? 2 : 1;
|
||||
this.printSequence(node.directives, node, {
|
||||
indent: true,
|
||||
trailingCommentsLineOffset: newline
|
||||
});
|
||||
|
||||
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) {
|
||||
this.print(node.value, node);
|
||||
this.semicolon();
|
||||
@@ -76,15 +61,12 @@ function Directive(node) {
|
||||
|
||||
const unescapedSingleQuoteRE = /(?:^|[^\\])(?:\\\\)*'/;
|
||||
const unescapedDoubleQuoteRE = /(?:^|[^\\])(?:\\\\)*"/;
|
||||
|
||||
function DirectiveLiteral(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
|
||||
if (!this.format.minified && raw !== undefined) {
|
||||
this.token(raw);
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
value
|
||||
} = node;
|
||||
@@ -97,17 +79,14 @@ function DirectiveLiteral(node) {
|
||||
throw new Error("Malformed AST: it is not possible to print a directive containing" + " both unescaped single and double quotes.");
|
||||
}
|
||||
}
|
||||
|
||||
function InterpreterDirective(node) {
|
||||
this.token(`#!${node.value}`);
|
||||
this.newline(1, true);
|
||||
}
|
||||
|
||||
function Placeholder(node) {
|
||||
this.token("%%");
|
||||
this.print(node.name);
|
||||
this.token("%%");
|
||||
|
||||
if (node.expectedNode === "Statement") {
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
54
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/classes.js
generated
vendored
54
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/classes.js
generated
vendored
@@ -12,41 +12,31 @@ exports.ClassPrivateProperty = ClassPrivateProperty;
|
||||
exports.ClassProperty = ClassProperty;
|
||||
exports.StaticBlock = StaticBlock;
|
||||
exports._classMethodHead = _classMethodHead;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
isExportDefaultDeclaration,
|
||||
isExportNamedDeclaration
|
||||
} = _t;
|
||||
|
||||
function ClassDeclaration(node, parent) {
|
||||
{
|
||||
if (!this.format.decoratorsBeforeExport || !isExportDefaultDeclaration(parent) && !isExportNamedDeclaration(parent)) {
|
||||
this.printJoin(node.decorators, node);
|
||||
}
|
||||
}
|
||||
|
||||
if (node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.abstract) {
|
||||
this.word("abstract");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("class");
|
||||
this.printInnerComments(node);
|
||||
|
||||
if (node.id) {
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
}
|
||||
|
||||
this.print(node.typeParameters, node);
|
||||
|
||||
if (node.superClass) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
@@ -54,22 +44,17 @@ function ClassDeclaration(node, parent) {
|
||||
this.print(node.superClass, node);
|
||||
this.print(node.superTypeParameters, node);
|
||||
}
|
||||
|
||||
if (node.implements) {
|
||||
this.space();
|
||||
this.word("implements");
|
||||
this.space();
|
||||
this.printList(node.implements, node);
|
||||
}
|
||||
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function ClassBody(node) {
|
||||
this.tokenChar(123);
|
||||
this.printInnerComments(node);
|
||||
|
||||
if (node.body.length === 0) {
|
||||
this.tokenChar(125);
|
||||
} else {
|
||||
@@ -82,137 +67,110 @@ function ClassBody(node) {
|
||||
this.rightBrace();
|
||||
}
|
||||
}
|
||||
|
||||
function ClassProperty(node) {
|
||||
var _node$key$loc, _node$key$loc$end;
|
||||
|
||||
this.printJoin(node.decorators, node);
|
||||
|
||||
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) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.key, node);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
this._variance(node);
|
||||
|
||||
this.print(node.key, node);
|
||||
}
|
||||
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
|
||||
if (node.definite) {
|
||||
this.tokenChar(33);
|
||||
}
|
||||
|
||||
this.print(node.typeAnnotation, node);
|
||||
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function ClassAccessorProperty(node) {
|
||||
var _node$key$loc2, _node$key$loc2$end;
|
||||
|
||||
this.printJoin(node.decorators, node);
|
||||
|
||||
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);
|
||||
this.space();
|
||||
|
||||
this.tsPrintClassMemberModifiers(node);
|
||||
this.word("accessor", true);
|
||||
this.space();
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.key, node);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
this._variance(node);
|
||||
|
||||
this.print(node.key, node);
|
||||
}
|
||||
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
|
||||
if (node.definite) {
|
||||
this.tokenChar(33);
|
||||
}
|
||||
|
||||
this.print(node.typeAnnotation, node);
|
||||
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function ClassPrivateProperty(node) {
|
||||
this.printJoin(node.decorators, node);
|
||||
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.key, node);
|
||||
this.print(node.typeAnnotation, node);
|
||||
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function ClassMethod(node) {
|
||||
this._classMethodHead(node);
|
||||
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function ClassPrivateMethod(node) {
|
||||
this._classMethodHead(node);
|
||||
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function _classMethodHead(node) {
|
||||
var _node$key$loc3, _node$key$loc3$end;
|
||||
|
||||
this.printJoin(node.decorators, node);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
function StaticBlock(node) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
this.tokenChar(123);
|
||||
|
||||
if (node.body.length === 0) {
|
||||
this.tokenChar(125);
|
||||
} else {
|
||||
|
||||
81
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/expressions.js
generated
vendored
81
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/expressions.js
generated
vendored
@@ -29,49 +29,38 @@ exports.UnaryExpression = UnaryExpression;
|
||||
exports.UpdateExpression = UpdateExpression;
|
||||
exports.V8IntrinsicIdentifier = V8IntrinsicIdentifier;
|
||||
exports.YieldExpression = YieldExpression;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var n = require("../node");
|
||||
|
||||
const {
|
||||
isCallExpression,
|
||||
isLiteral,
|
||||
isMemberExpression,
|
||||
isNewExpression
|
||||
} = _t;
|
||||
|
||||
function UnaryExpression(node) {
|
||||
if (node.operator === "void" || node.operator === "delete" || node.operator === "typeof" || node.operator === "throw") {
|
||||
if (node.operator === "void" || node.operator === "delete" || node.operator === "typeof" ||
|
||||
node.operator === "throw") {
|
||||
this.word(node.operator);
|
||||
this.space();
|
||||
} else {
|
||||
this.token(node.operator);
|
||||
}
|
||||
|
||||
this.print(node.argument, node);
|
||||
}
|
||||
|
||||
function DoExpression(node) {
|
||||
if (node.async) {
|
||||
this.word("async");
|
||||
this.ensureNoLineTerminator(() => {
|
||||
this.printInnerComments(node);
|
||||
this.space();
|
||||
});
|
||||
this.word("async", true);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("do");
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function ParenthesizedExpression(node) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.expression, node);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
|
||||
function UpdateExpression(node) {
|
||||
if (node.prefix) {
|
||||
this.token(node.operator);
|
||||
@@ -81,7 +70,6 @@ function UpdateExpression(node) {
|
||||
this.token(node.operator);
|
||||
}
|
||||
}
|
||||
|
||||
function ConditionalExpression(node) {
|
||||
this.print(node.test, node);
|
||||
this.space();
|
||||
@@ -93,69 +81,55 @@ function ConditionalExpression(node) {
|
||||
this.space();
|
||||
this.print(node.alternate, node);
|
||||
}
|
||||
|
||||
function NewExpression(node, parent) {
|
||||
this.word("new");
|
||||
this.space();
|
||||
this.print(node.callee, node);
|
||||
|
||||
if (this.format.minified && node.arguments.length === 0 && !node.optional && !isCallExpression(parent, {
|
||||
callee: node
|
||||
}) && !isMemberExpression(parent) && !isNewExpression(parent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.print(node.typeArguments, node);
|
||||
this.print(node.typeParameters, node);
|
||||
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
|
||||
this.tokenChar(40);
|
||||
this.printList(node.arguments, node);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
|
||||
function SequenceExpression(node) {
|
||||
this.printList(node.expressions, node);
|
||||
}
|
||||
|
||||
function ThisExpression() {
|
||||
this.word("this");
|
||||
}
|
||||
|
||||
function Super() {
|
||||
this.word("super");
|
||||
}
|
||||
|
||||
function isDecoratorMemberExpression(node) {
|
||||
switch (node.type) {
|
||||
case "Identifier":
|
||||
return true;
|
||||
|
||||
case "MemberExpression":
|
||||
return !node.computed && node.property.type === "Identifier" && isDecoratorMemberExpression(node.object);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function shouldParenthesizeDecoratorExpression(node) {
|
||||
if (node.type === "ParenthesizedExpression") {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !isDecoratorMemberExpression(node.type === "CallExpression" ? node.callee : node);
|
||||
}
|
||||
|
||||
function Decorator(node) {
|
||||
this.tokenChar(64);
|
||||
const {
|
||||
expression
|
||||
} = node;
|
||||
|
||||
if (shouldParenthesizeDecoratorExpression(expression)) {
|
||||
this.tokenChar(40);
|
||||
this.print(expression, node);
|
||||
@@ -163,27 +137,20 @@ function Decorator(node) {
|
||||
} else {
|
||||
this.print(expression, node);
|
||||
}
|
||||
|
||||
this.newline();
|
||||
}
|
||||
|
||||
function OptionalMemberExpression(node) {
|
||||
this.print(node.object, node);
|
||||
|
||||
if (!node.computed && isMemberExpression(node.property)) {
|
||||
throw new TypeError("Got a MemberExpression for MemberExpression property");
|
||||
}
|
||||
|
||||
let computed = node.computed;
|
||||
|
||||
if (isLiteral(node.property) && typeof node.property.value === "number") {
|
||||
computed = true;
|
||||
}
|
||||
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
|
||||
if (computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.property, node);
|
||||
@@ -192,11 +159,9 @@ function OptionalMemberExpression(node) {
|
||||
if (!node.optional) {
|
||||
this.tokenChar(46);
|
||||
}
|
||||
|
||||
this.print(node.property, node);
|
||||
}
|
||||
}
|
||||
|
||||
function OptionalCallExpression(node) {
|
||||
this.print(node.callee, node);
|
||||
this.print(node.typeParameters, node);
|
||||
@@ -204,13 +169,12 @@ function OptionalCallExpression(node) {
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
|
||||
this.print(node.typeArguments, node);
|
||||
|
||||
this.tokenChar(40);
|
||||
this.printList(node.arguments, node);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
|
||||
function CallExpression(node) {
|
||||
this.print(node.callee, node);
|
||||
this.print(node.typeArguments, node);
|
||||
@@ -219,29 +183,23 @@ function CallExpression(node) {
|
||||
this.printList(node.arguments, node);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
|
||||
function Import() {
|
||||
this.word("import");
|
||||
}
|
||||
|
||||
function AwaitExpression(node) {
|
||||
this.word("await");
|
||||
|
||||
if (node.argument) {
|
||||
this.space();
|
||||
this.printTerminatorless(node.argument, node, false);
|
||||
}
|
||||
}
|
||||
|
||||
function YieldExpression(node) {
|
||||
this.word("yield");
|
||||
|
||||
this.word("yield", true);
|
||||
if (node.delegate) {
|
||||
this.ensureNoLineTerminator(() => {
|
||||
this.printInnerComments(node);
|
||||
});
|
||||
this.tokenChar(42);
|
||||
|
||||
if (node.argument) {
|
||||
this.space();
|
||||
this.print(node.argument, node);
|
||||
@@ -253,7 +211,6 @@ function YieldExpression(node) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function EmptyStatement() {
|
||||
this.semicolon(true);
|
||||
}
|
||||
@@ -262,7 +219,6 @@ function ExpressionStatement(node) {
|
||||
this.print(node.expression, node);
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function AssignmentPattern(node) {
|
||||
this.print(node.left, node);
|
||||
if (node.left.optional) this.tokenChar(63);
|
||||
@@ -272,50 +228,38 @@ function AssignmentPattern(node) {
|
||||
this.space();
|
||||
this.print(node.right, node);
|
||||
}
|
||||
|
||||
function AssignmentExpression(node, parent) {
|
||||
const parens = this.inForStatementInitCounter && node.operator === "in" && !n.needsParens(node, parent);
|
||||
|
||||
if (parens) {
|
||||
this.tokenChar(40);
|
||||
}
|
||||
|
||||
this.print(node.left, node);
|
||||
this.space();
|
||||
|
||||
if (node.operator === "in" || node.operator === "instanceof") {
|
||||
this.word(node.operator);
|
||||
} else {
|
||||
this.token(node.operator);
|
||||
}
|
||||
|
||||
this.space();
|
||||
this.print(node.right, node);
|
||||
|
||||
if (parens) {
|
||||
this.tokenChar(41);
|
||||
}
|
||||
}
|
||||
|
||||
function BindExpression(node) {
|
||||
this.print(node.object, node);
|
||||
this.token("::");
|
||||
this.print(node.callee, node);
|
||||
}
|
||||
|
||||
function MemberExpression(node) {
|
||||
this.print(node.object, node);
|
||||
|
||||
if (!node.computed && isMemberExpression(node.property)) {
|
||||
throw new TypeError("Got a MemberExpression for MemberExpression property");
|
||||
}
|
||||
|
||||
let computed = node.computed;
|
||||
|
||||
if (isLiteral(node.property) && typeof node.property.value === "number") {
|
||||
computed = true;
|
||||
}
|
||||
|
||||
if (computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.property, node);
|
||||
@@ -325,39 +269,30 @@ function MemberExpression(node) {
|
||||
this.print(node.property, node);
|
||||
}
|
||||
}
|
||||
|
||||
function MetaProperty(node) {
|
||||
this.print(node.meta, node);
|
||||
this.tokenChar(46);
|
||||
this.print(node.property, node);
|
||||
}
|
||||
|
||||
function PrivateName(node) {
|
||||
this.tokenChar(35);
|
||||
this.print(node.id, node);
|
||||
}
|
||||
|
||||
function V8IntrinsicIdentifier(node) {
|
||||
this.tokenChar(37);
|
||||
this.word(node.name);
|
||||
}
|
||||
|
||||
function ModuleExpression(node) {
|
||||
this.word("module");
|
||||
this.ensureNoLineTerminator(() => {
|
||||
this.printInnerComments(node);
|
||||
this.space();
|
||||
});
|
||||
this.word("module", true);
|
||||
this.space();
|
||||
this.tokenChar(123);
|
||||
this.indent();
|
||||
const {
|
||||
body
|
||||
} = node;
|
||||
|
||||
if (body.body.length || body.directives.length) {
|
||||
this.newline();
|
||||
}
|
||||
|
||||
this.print(body, node);
|
||||
this.dedent();
|
||||
this.sourceWithOffset("end", node.loc, 0, -1);
|
||||
|
||||
135
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/flow.js
generated
vendored
135
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/flow.js
generated
vendored
@@ -77,76 +77,58 @@ exports.Variance = Variance;
|
||||
exports.VoidTypeAnnotation = VoidTypeAnnotation;
|
||||
exports._interfaceish = _interfaceish;
|
||||
exports._variance = _variance;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var _modules = require("./modules");
|
||||
|
||||
var _types2 = require("./types");
|
||||
|
||||
const {
|
||||
isDeclareExportDeclaration,
|
||||
isStatement
|
||||
} = _t;
|
||||
|
||||
function AnyTypeAnnotation() {
|
||||
this.word("any");
|
||||
}
|
||||
|
||||
function ArrayTypeAnnotation(node) {
|
||||
this.print(node.elementType, node, true);
|
||||
this.tokenChar(91);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
|
||||
function BooleanTypeAnnotation() {
|
||||
this.word("boolean");
|
||||
}
|
||||
|
||||
function BooleanLiteralTypeAnnotation(node) {
|
||||
this.word(node.value ? "true" : "false");
|
||||
}
|
||||
|
||||
function NullLiteralTypeAnnotation() {
|
||||
this.word("null");
|
||||
}
|
||||
|
||||
function DeclareClass(node, parent) {
|
||||
if (!isDeclareExportDeclaration(parent)) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("class");
|
||||
this.space();
|
||||
|
||||
this._interfaceish(node);
|
||||
}
|
||||
|
||||
function DeclareFunction(node, parent) {
|
||||
if (!isDeclareExportDeclaration(parent)) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("function");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.id.typeAnnotation.typeAnnotation, node);
|
||||
|
||||
if (node.predicate) {
|
||||
this.space();
|
||||
this.print(node.predicate, node);
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function InferredPredicate() {
|
||||
this.tokenChar(37);
|
||||
this.word("checks");
|
||||
}
|
||||
|
||||
function DeclaredPredicate(node) {
|
||||
this.tokenChar(37);
|
||||
this.word("checks");
|
||||
@@ -154,13 +136,11 @@ function DeclaredPredicate(node) {
|
||||
this.print(node.value, node);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
|
||||
function DeclareInterface(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
this.InterfaceDeclaration(node);
|
||||
}
|
||||
|
||||
function DeclareModule(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
@@ -170,7 +150,6 @@ function DeclareModule(node) {
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function DeclareModuleExports(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
@@ -179,56 +158,45 @@ function DeclareModuleExports(node) {
|
||||
this.word("exports");
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
function DeclareTypeAlias(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
this.TypeAlias(node);
|
||||
}
|
||||
|
||||
function DeclareOpaqueType(node, parent) {
|
||||
if (!isDeclareExportDeclaration(parent)) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.OpaqueType(node);
|
||||
}
|
||||
|
||||
function DeclareVariable(node, parent) {
|
||||
if (!isDeclareExportDeclaration(parent)) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("var");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.id.typeAnnotation, node);
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function DeclareExportDeclaration(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
this.word("export");
|
||||
this.space();
|
||||
|
||||
if (node.default) {
|
||||
this.word("default");
|
||||
this.space();
|
||||
}
|
||||
|
||||
FlowExportDeclaration.call(this, node);
|
||||
}
|
||||
|
||||
function DeclareExportAllDeclaration(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
|
||||
_modules.ExportAllDeclaration.call(this, node);
|
||||
}
|
||||
|
||||
function EnumDeclaration(node) {
|
||||
const {
|
||||
id,
|
||||
@@ -239,7 +207,6 @@ function EnumDeclaration(node) {
|
||||
this.print(id, node);
|
||||
this.print(body, node);
|
||||
}
|
||||
|
||||
function enumExplicitType(context, name, hasExplicitType) {
|
||||
if (hasExplicitType) {
|
||||
context.space();
|
||||
@@ -247,10 +214,8 @@ function enumExplicitType(context, name, hasExplicitType) {
|
||||
context.space();
|
||||
context.word(name);
|
||||
}
|
||||
|
||||
context.space();
|
||||
}
|
||||
|
||||
function enumBody(context, node) {
|
||||
const {
|
||||
members
|
||||
@@ -258,21 +223,17 @@ function enumBody(context, node) {
|
||||
context.token("{");
|
||||
context.indent();
|
||||
context.newline();
|
||||
|
||||
for (const member of members) {
|
||||
context.print(member, node);
|
||||
context.newline();
|
||||
}
|
||||
|
||||
if (node.hasUnknownMembers) {
|
||||
context.token("...");
|
||||
context.newline();
|
||||
}
|
||||
|
||||
context.dedent();
|
||||
context.token("}");
|
||||
}
|
||||
|
||||
function EnumBooleanBody(node) {
|
||||
const {
|
||||
explicitType
|
||||
@@ -280,7 +241,6 @@ function EnumBooleanBody(node) {
|
||||
enumExplicitType(this, "boolean", explicitType);
|
||||
enumBody(this, node);
|
||||
}
|
||||
|
||||
function EnumNumberBody(node) {
|
||||
const {
|
||||
explicitType
|
||||
@@ -288,7 +248,6 @@ function EnumNumberBody(node) {
|
||||
enumExplicitType(this, "number", explicitType);
|
||||
enumBody(this, node);
|
||||
}
|
||||
|
||||
function EnumStringBody(node) {
|
||||
const {
|
||||
explicitType
|
||||
@@ -296,12 +255,10 @@ function EnumStringBody(node) {
|
||||
enumExplicitType(this, "string", explicitType);
|
||||
enumBody(this, node);
|
||||
}
|
||||
|
||||
function EnumSymbolBody(node) {
|
||||
enumExplicitType(this, "symbol", true);
|
||||
enumBody(this, node);
|
||||
}
|
||||
|
||||
function EnumDefaultedMember(node) {
|
||||
const {
|
||||
id
|
||||
@@ -309,7 +266,6 @@ function EnumDefaultedMember(node) {
|
||||
this.print(id, node);
|
||||
this.tokenChar(44);
|
||||
}
|
||||
|
||||
function enumInitializedMember(context, node) {
|
||||
const {
|
||||
id,
|
||||
@@ -322,19 +278,15 @@ function enumInitializedMember(context, node) {
|
||||
context.print(init, node);
|
||||
context.token(",");
|
||||
}
|
||||
|
||||
function EnumBooleanMember(node) {
|
||||
enumInitializedMember(this, node);
|
||||
}
|
||||
|
||||
function EnumNumberMember(node) {
|
||||
enumInitializedMember(this, node);
|
||||
}
|
||||
|
||||
function EnumStringMember(node) {
|
||||
enumInitializedMember(this, node);
|
||||
}
|
||||
|
||||
function FlowExportDeclaration(node) {
|
||||
if (node.declaration) {
|
||||
const declar = node.declaration;
|
||||
@@ -342,58 +294,46 @@ function FlowExportDeclaration(node) {
|
||||
if (!isStatement(declar)) this.semicolon();
|
||||
} else {
|
||||
this.tokenChar(123);
|
||||
|
||||
if (node.specifiers.length) {
|
||||
this.space();
|
||||
this.printList(node.specifiers, node);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.tokenChar(125);
|
||||
|
||||
if (node.source) {
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
this.print(node.source, node);
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
}
|
||||
|
||||
function ExistsTypeAnnotation() {
|
||||
this.tokenChar(42);
|
||||
}
|
||||
|
||||
function FunctionTypeAnnotation(node, parent) {
|
||||
this.print(node.typeParameters, node);
|
||||
this.tokenChar(40);
|
||||
|
||||
if (node.this) {
|
||||
this.word("this");
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.this.typeAnnotation, node);
|
||||
|
||||
if (node.params.length || node.rest) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
}
|
||||
|
||||
this.printList(node.params, node);
|
||||
|
||||
if (node.rest) {
|
||||
if (node.params.length) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.token("...");
|
||||
this.print(node.rest, node);
|
||||
}
|
||||
|
||||
this.tokenChar(41);
|
||||
|
||||
if (parent && (parent.type === "ObjectTypeCallProperty" || parent.type === "ObjectTypeInternalSlot" || parent.type === "DeclareFunction" || parent.type === "ObjectTypeProperty" && parent.method)) {
|
||||
@@ -402,59 +342,47 @@ function FunctionTypeAnnotation(node, parent) {
|
||||
this.space();
|
||||
this.token("=>");
|
||||
}
|
||||
|
||||
this.space();
|
||||
this.print(node.returnType, node);
|
||||
}
|
||||
|
||||
function FunctionTypeParam(node) {
|
||||
this.print(node.name, node);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
|
||||
if (node.name) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
function InterfaceExtends(node) {
|
||||
this.print(node.id, node);
|
||||
this.print(node.typeParameters, node, true);
|
||||
}
|
||||
|
||||
function _interfaceish(node) {
|
||||
var _node$extends;
|
||||
|
||||
this.print(node.id, node);
|
||||
this.print(node.typeParameters, node);
|
||||
|
||||
if ((_node$extends = node.extends) != null && _node$extends.length) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(node.extends, node);
|
||||
}
|
||||
|
||||
if (node.mixins && node.mixins.length) {
|
||||
this.space();
|
||||
this.word("mixins");
|
||||
this.space();
|
||||
this.printList(node.mixins, node);
|
||||
}
|
||||
|
||||
if (node.implements && node.implements.length) {
|
||||
this.space();
|
||||
this.word("implements");
|
||||
this.space();
|
||||
this.printList(node.implements, node);
|
||||
}
|
||||
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function _variance(node) {
|
||||
if (node.variance) {
|
||||
if (node.variance.kind === "plus") {
|
||||
@@ -464,77 +392,61 @@ function _variance(node) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function InterfaceDeclaration(node) {
|
||||
this.word("interface");
|
||||
this.space();
|
||||
|
||||
this._interfaceish(node);
|
||||
}
|
||||
|
||||
function andSeparator() {
|
||||
this.space();
|
||||
this.tokenChar(38);
|
||||
this.space();
|
||||
}
|
||||
|
||||
function InterfaceTypeAnnotation(node) {
|
||||
this.word("interface");
|
||||
|
||||
if (node.extends && node.extends.length) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(node.extends, node);
|
||||
}
|
||||
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function IntersectionTypeAnnotation(node) {
|
||||
this.printJoin(node.types, node, {
|
||||
separator: andSeparator
|
||||
});
|
||||
}
|
||||
|
||||
function MixedTypeAnnotation() {
|
||||
this.word("mixed");
|
||||
}
|
||||
|
||||
function EmptyTypeAnnotation() {
|
||||
this.word("empty");
|
||||
}
|
||||
|
||||
function NullableTypeAnnotation(node) {
|
||||
this.tokenChar(63);
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
function NumberTypeAnnotation() {
|
||||
this.word("number");
|
||||
}
|
||||
|
||||
function StringTypeAnnotation() {
|
||||
this.word("string");
|
||||
}
|
||||
|
||||
function ThisTypeAnnotation() {
|
||||
this.word("this");
|
||||
}
|
||||
|
||||
function TupleTypeAnnotation(node) {
|
||||
this.tokenChar(91);
|
||||
this.printList(node.types, node);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
|
||||
function TypeofTypeAnnotation(node) {
|
||||
this.word("typeof");
|
||||
this.space();
|
||||
this.print(node.argument, node);
|
||||
}
|
||||
|
||||
function TypeAlias(node) {
|
||||
this.word("type");
|
||||
this.space();
|
||||
@@ -546,29 +458,23 @@ function TypeAlias(node) {
|
||||
this.print(node.right, node);
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function TypeAnnotation(node) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
if (node.optional) this.tokenChar(63);
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
function TypeParameterInstantiation(node) {
|
||||
this.tokenChar(60);
|
||||
this.printList(node.params, node, {});
|
||||
this.tokenChar(62);
|
||||
}
|
||||
|
||||
function TypeParameter(node) {
|
||||
this._variance(node);
|
||||
|
||||
this.word(node.name);
|
||||
|
||||
if (node.bound) {
|
||||
this.print(node.bound, node);
|
||||
}
|
||||
|
||||
if (node.default) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
@@ -576,7 +482,6 @@ function TypeParameter(node) {
|
||||
this.print(node.default, node);
|
||||
}
|
||||
}
|
||||
|
||||
function OpaqueType(node) {
|
||||
this.word("opaque");
|
||||
this.space();
|
||||
@@ -584,23 +489,19 @@ function OpaqueType(node) {
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.typeParameters, node);
|
||||
|
||||
if (node.supertype) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.supertype, node);
|
||||
}
|
||||
|
||||
if (node.impltype) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.impltype, node);
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function ObjectTypeAnnotation(node) {
|
||||
if (node.exact) {
|
||||
this.token("{|");
|
||||
@@ -609,7 +510,6 @@ function ObjectTypeAnnotation(node) {
|
||||
}
|
||||
|
||||
const props = [...node.properties, ...(node.callProperties || []), ...(node.indexers || []), ...(node.internalSlots || [])];
|
||||
|
||||
if (props.length) {
|
||||
this.newline();
|
||||
this.space();
|
||||
@@ -617,7 +517,6 @@ function ObjectTypeAnnotation(node) {
|
||||
addNewlines(leading) {
|
||||
if (leading && !props[0]) return 1;
|
||||
},
|
||||
|
||||
indent: true,
|
||||
statement: true,
|
||||
iterator: () => {
|
||||
@@ -629,141 +528,112 @@ function ObjectTypeAnnotation(node) {
|
||||
});
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.inexact) {
|
||||
this.indent();
|
||||
this.token("...");
|
||||
|
||||
if (props.length) {
|
||||
this.newline();
|
||||
}
|
||||
|
||||
this.dedent();
|
||||
}
|
||||
|
||||
if (node.exact) {
|
||||
this.token("|}");
|
||||
} else {
|
||||
this.tokenChar(125);
|
||||
}
|
||||
}
|
||||
|
||||
function ObjectTypeInternalSlot(node) {
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.tokenChar(91);
|
||||
this.tokenChar(91);
|
||||
this.print(node.id, node);
|
||||
this.tokenChar(93);
|
||||
this.tokenChar(93);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
|
||||
if (!node.method) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.value, node);
|
||||
}
|
||||
|
||||
function ObjectTypeCallProperty(node) {
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.value, node);
|
||||
}
|
||||
|
||||
function ObjectTypeIndexer(node) {
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this._variance(node);
|
||||
|
||||
this.tokenChar(91);
|
||||
|
||||
if (node.id) {
|
||||
this.print(node.id, node);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.key, node);
|
||||
this.tokenChar(93);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
}
|
||||
|
||||
function ObjectTypeProperty(node) {
|
||||
if (node.proto) {
|
||||
this.word("proto");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.kind === "get" || node.kind === "set") {
|
||||
this.word(node.kind);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this._variance(node);
|
||||
|
||||
this.print(node.key, node);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
|
||||
if (!node.method) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.value, node);
|
||||
}
|
||||
|
||||
function ObjectTypeSpreadProperty(node) {
|
||||
this.token("...");
|
||||
this.print(node.argument, node);
|
||||
}
|
||||
|
||||
function QualifiedTypeIdentifier(node) {
|
||||
this.print(node.qualification, node);
|
||||
this.tokenChar(46);
|
||||
this.print(node.id, node);
|
||||
}
|
||||
|
||||
function SymbolTypeAnnotation() {
|
||||
this.word("symbol");
|
||||
}
|
||||
|
||||
function orSeparator() {
|
||||
this.space();
|
||||
this.tokenChar(124);
|
||||
this.space();
|
||||
}
|
||||
|
||||
function UnionTypeAnnotation(node) {
|
||||
this.printJoin(node.types, node, {
|
||||
separator: orSeparator
|
||||
});
|
||||
}
|
||||
|
||||
function TypeCastExpression(node) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.expression, node);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
|
||||
function Variance(node) {
|
||||
if (node.kind === "plus") {
|
||||
this.tokenChar(43);
|
||||
@@ -771,25 +641,20 @@ function Variance(node) {
|
||||
this.tokenChar(45);
|
||||
}
|
||||
}
|
||||
|
||||
function VoidTypeAnnotation() {
|
||||
this.word("void");
|
||||
}
|
||||
|
||||
function IndexedAccessType(node) {
|
||||
this.print(node.objectType, node, true);
|
||||
this.tokenChar(91);
|
||||
this.print(node.indexType, node);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
|
||||
function OptionalIndexedAccessType(node) {
|
||||
this.print(node.objectType, node);
|
||||
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
|
||||
this.tokenChar(91);
|
||||
this.print(node.indexType, node);
|
||||
this.tokenChar(93);
|
||||
|
||||
22
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/index.js
generated
vendored
22
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/index.js
generated
vendored
@@ -3,9 +3,7 @@
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _templateLiterals = require("./template-literals");
|
||||
|
||||
Object.keys(_templateLiterals).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _templateLiterals[key]) return;
|
||||
@@ -16,9 +14,7 @@ Object.keys(_templateLiterals).forEach(function (key) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _expressions = require("./expressions");
|
||||
|
||||
Object.keys(_expressions).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _expressions[key]) return;
|
||||
@@ -29,9 +25,7 @@ Object.keys(_expressions).forEach(function (key) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _statements = require("./statements");
|
||||
|
||||
Object.keys(_statements).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _statements[key]) return;
|
||||
@@ -42,9 +36,7 @@ Object.keys(_statements).forEach(function (key) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _classes = require("./classes");
|
||||
|
||||
Object.keys(_classes).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _classes[key]) return;
|
||||
@@ -55,9 +47,7 @@ Object.keys(_classes).forEach(function (key) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _methods = require("./methods");
|
||||
|
||||
Object.keys(_methods).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _methods[key]) return;
|
||||
@@ -68,9 +58,7 @@ Object.keys(_methods).forEach(function (key) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _modules = require("./modules");
|
||||
|
||||
Object.keys(_modules).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _modules[key]) return;
|
||||
@@ -81,9 +69,7 @@ Object.keys(_modules).forEach(function (key) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _types = require("./types");
|
||||
|
||||
Object.keys(_types).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _types[key]) return;
|
||||
@@ -94,9 +80,7 @@ Object.keys(_types).forEach(function (key) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _flow = require("./flow");
|
||||
|
||||
Object.keys(_flow).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _flow[key]) return;
|
||||
@@ -107,9 +91,7 @@ Object.keys(_flow).forEach(function (key) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _base = require("./base");
|
||||
|
||||
Object.keys(_base).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _base[key]) return;
|
||||
@@ -120,9 +102,7 @@ Object.keys(_base).forEach(function (key) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _jsx = require("./jsx");
|
||||
|
||||
Object.keys(_jsx).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _jsx[key]) return;
|
||||
@@ -133,9 +113,7 @@ Object.keys(_jsx).forEach(function (key) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _typescript = require("./typescript");
|
||||
|
||||
Object.keys(_typescript).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _typescript[key]) return;
|
||||
|
||||
28
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/jsx.js
generated
vendored
28
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/jsx.js
generated
vendored
@@ -18,92 +18,75 @@ exports.JSXOpeningFragment = JSXOpeningFragment;
|
||||
exports.JSXSpreadAttribute = JSXSpreadAttribute;
|
||||
exports.JSXSpreadChild = JSXSpreadChild;
|
||||
exports.JSXText = JSXText;
|
||||
|
||||
function JSXAttribute(node) {
|
||||
this.print(node.name, node);
|
||||
|
||||
if (node.value) {
|
||||
this.tokenChar(61);
|
||||
this.print(node.value, node);
|
||||
}
|
||||
}
|
||||
|
||||
function JSXIdentifier(node) {
|
||||
this.word(node.name);
|
||||
}
|
||||
|
||||
function JSXNamespacedName(node) {
|
||||
this.print(node.namespace, node);
|
||||
this.tokenChar(58);
|
||||
this.print(node.name, node);
|
||||
}
|
||||
|
||||
function JSXMemberExpression(node) {
|
||||
this.print(node.object, node);
|
||||
this.tokenChar(46);
|
||||
this.print(node.property, node);
|
||||
}
|
||||
|
||||
function JSXSpreadAttribute(node) {
|
||||
this.tokenChar(123);
|
||||
this.token("...");
|
||||
this.print(node.argument, node);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
function JSXExpressionContainer(node) {
|
||||
this.tokenChar(123);
|
||||
this.print(node.expression, node);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
function JSXSpreadChild(node) {
|
||||
this.tokenChar(123);
|
||||
this.token("...");
|
||||
this.print(node.expression, node);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
function JSXText(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
|
||||
if (raw !== undefined) {
|
||||
this.token(raw, true);
|
||||
} else {
|
||||
this.token(node.value, true);
|
||||
}
|
||||
}
|
||||
|
||||
function JSXElement(node) {
|
||||
const open = node.openingElement;
|
||||
this.print(open, node);
|
||||
if (open.selfClosing) return;
|
||||
this.indent();
|
||||
|
||||
for (const child of node.children) {
|
||||
this.print(child, node);
|
||||
}
|
||||
|
||||
this.dedent();
|
||||
this.print(node.closingElement, node);
|
||||
}
|
||||
|
||||
function spaceSeparator() {
|
||||
this.space();
|
||||
}
|
||||
|
||||
function JSXOpeningElement(node) {
|
||||
this.tokenChar(60);
|
||||
this.print(node.name, node);
|
||||
this.print(node.typeParameters, node);
|
||||
|
||||
if (node.attributes.length > 0) {
|
||||
this.space();
|
||||
this.printJoin(node.attributes, node, {
|
||||
separator: spaceSeparator
|
||||
});
|
||||
}
|
||||
|
||||
if (node.selfClosing) {
|
||||
this.space();
|
||||
this.token("/>");
|
||||
@@ -111,34 +94,27 @@ function JSXOpeningElement(node) {
|
||||
this.tokenChar(62);
|
||||
}
|
||||
}
|
||||
|
||||
function JSXClosingElement(node) {
|
||||
this.token("</");
|
||||
this.print(node.name, node);
|
||||
this.tokenChar(62);
|
||||
}
|
||||
|
||||
function JSXEmptyExpression(node) {
|
||||
this.printInnerComments(node);
|
||||
function JSXEmptyExpression() {
|
||||
this.printInnerComments();
|
||||
}
|
||||
|
||||
function JSXFragment(node) {
|
||||
this.print(node.openingFragment, node);
|
||||
this.indent();
|
||||
|
||||
for (const child of node.children) {
|
||||
this.print(child, node);
|
||||
}
|
||||
|
||||
this.dedent();
|
||||
this.print(node.closingFragment, node);
|
||||
}
|
||||
|
||||
function JSXOpeningFragment() {
|
||||
this.tokenChar(60);
|
||||
this.tokenChar(62);
|
||||
}
|
||||
|
||||
function JSXClosingFragment() {
|
||||
this.token("</");
|
||||
this.tokenChar(62);
|
||||
|
||||
78
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/methods.js
generated
vendored
78
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/methods.js
generated
vendored
@@ -11,29 +11,22 @@ exports._param = _param;
|
||||
exports._parameters = _parameters;
|
||||
exports._params = _params;
|
||||
exports._predicate = _predicate;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
isIdentifier
|
||||
} = _t;
|
||||
|
||||
function _params(node) {
|
||||
this.print(node.typeParameters, node);
|
||||
this.tokenChar(40);
|
||||
|
||||
this._parameters(node.params, node);
|
||||
|
||||
this.tokenChar(41);
|
||||
this._noLineTerminator = true;
|
||||
this.print(node.returnType, node, node.type === "ArrowFunctionExpression");
|
||||
}
|
||||
|
||||
function _parameters(parameters, parent) {
|
||||
const paramLength = parameters.length;
|
||||
|
||||
for (let i = 0; i < paramLength; i++) {
|
||||
this._param(parameters[i], parent);
|
||||
|
||||
if (i < parameters.length - 1) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
@@ -44,38 +37,31 @@ function _parameters(parameters, parent) {
|
||||
this.printInnerComments(parent);
|
||||
}
|
||||
}
|
||||
|
||||
function _param(parameter, parent) {
|
||||
this.printJoin(parameter.decorators, parameter);
|
||||
this.print(parameter, parent);
|
||||
|
||||
if (parameter.optional) {
|
||||
if (
|
||||
parameter.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
|
||||
this.print(parameter.typeAnnotation, parameter);
|
||||
this.print(
|
||||
parameter.typeAnnotation, parameter);
|
||||
}
|
||||
|
||||
function _methodHead(node) {
|
||||
const kind = node.kind;
|
||||
const key = node.key;
|
||||
|
||||
if (kind === "get" || kind === "set") {
|
||||
this.word(kind);
|
||||
this.space();
|
||||
}
|
||||
|
||||
const {
|
||||
_noLineTerminator
|
||||
} = this;
|
||||
|
||||
if (node.async) {
|
||||
this._noLineTerminator = true;
|
||||
this.word("async");
|
||||
this.word("async", true);
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (kind === "method" || kind === "init") {
|
||||
if (kind === "method" ||
|
||||
kind === "init") {
|
||||
if (node.generator) {
|
||||
if (node.async) {
|
||||
this.printInnerComments(node);
|
||||
@@ -85,7 +71,6 @@ function _methodHead(node) {
|
||||
this._noLineTerminator = _noLineTerminator;
|
||||
}
|
||||
}
|
||||
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this._noLineTerminator = _noLineTerminator;
|
||||
@@ -96,90 +81,73 @@ function _methodHead(node) {
|
||||
this.print(key, node);
|
||||
this._noLineTerminator = _noLineTerminator;
|
||||
}
|
||||
|
||||
if (node.optional) {
|
||||
if (
|
||||
node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
|
||||
this._params(node);
|
||||
}
|
||||
|
||||
function _predicate(node) {
|
||||
function _predicate(node, noLineTerminatorAfter) {
|
||||
if (node.predicate) {
|
||||
if (!node.returnType) {
|
||||
this.tokenChar(58);
|
||||
}
|
||||
|
||||
this.space();
|
||||
this.print(node.predicate, node);
|
||||
this.print(node.predicate, node, noLineTerminatorAfter);
|
||||
}
|
||||
}
|
||||
|
||||
function _functionHead(node) {
|
||||
if (node.async) {
|
||||
this.word("async");
|
||||
this._endsWithInnerRaw = false;
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("function");
|
||||
if (node.generator) this.tokenChar(42);
|
||||
this.printInnerComments(node);
|
||||
if (node.generator) {
|
||||
this._endsWithInnerRaw = false;
|
||||
this.tokenChar(42);
|
||||
}
|
||||
this.space();
|
||||
|
||||
if (node.id) {
|
||||
this.print(node.id, node);
|
||||
}
|
||||
|
||||
this._params(node);
|
||||
|
||||
if (node.type !== "TSDeclareFunction") {
|
||||
this._predicate(node);
|
||||
}
|
||||
}
|
||||
|
||||
function FunctionExpression(node) {
|
||||
this._functionHead(node);
|
||||
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function ArrowFunctionExpression(node) {
|
||||
const {
|
||||
_noLineTerminator
|
||||
} = this;
|
||||
|
||||
if (node.async) {
|
||||
this._noLineTerminator = true;
|
||||
this.word("async");
|
||||
this.word("async", true);
|
||||
this.space();
|
||||
}
|
||||
|
||||
let firstParam;
|
||||
|
||||
if (!this.format.retainLines && node.params.length === 1 && isIdentifier(firstParam = node.params[0]) && !hasTypesOrComments(node, firstParam)) {
|
||||
this.print(firstParam, node);
|
||||
this._noLineTerminator = _noLineTerminator;
|
||||
this.print(firstParam, node, true);
|
||||
} else {
|
||||
this._noLineTerminator = _noLineTerminator;
|
||||
|
||||
this._params(node);
|
||||
}
|
||||
|
||||
this._predicate(node);
|
||||
|
||||
this.ensureNoLineTerminator(() => {
|
||||
this.space();
|
||||
this.printInnerComments(node);
|
||||
this.token("=>");
|
||||
});
|
||||
this._predicate(node, true);
|
||||
this.space();
|
||||
this.printInnerComments();
|
||||
this.token("=>");
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function hasTypesOrComments(node, param) {
|
||||
var _param$leadingComment, _param$trailingCommen;
|
||||
|
||||
return !!(node.typeParameters || node.returnType || node.predicate || param.typeAnnotation || param.optional || (_param$leadingComment = param.leadingComments) != null && _param$leadingComment.length || (_param$trailingCommen = param.trailingComments) != null && _param$trailingCommen.length);
|
||||
}
|
||||
|
||||
|
||||
87
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/modules.js
generated
vendored
87
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/modules.js
generated
vendored
@@ -14,9 +14,8 @@ exports.ImportDeclaration = ImportDeclaration;
|
||||
exports.ImportDefaultSpecifier = ImportDefaultSpecifier;
|
||||
exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
|
||||
exports.ImportSpecifier = ImportSpecifier;
|
||||
|
||||
exports._printAssertions = _printAssertions;
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
isClassDeclaration,
|
||||
isExportDefaultSpecifier,
|
||||
@@ -25,15 +24,12 @@ const {
|
||||
isImportNamespaceSpecifier,
|
||||
isStatement
|
||||
} = _t;
|
||||
|
||||
function ImportSpecifier(node) {
|
||||
if (node.importKind === "type" || node.importKind === "typeof") {
|
||||
this.word(node.importKind);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.imported, node);
|
||||
|
||||
if (node.local && node.local.name !== node.imported.name) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
@@ -41,23 +37,18 @@ function ImportSpecifier(node) {
|
||||
this.print(node.local, node);
|
||||
}
|
||||
}
|
||||
|
||||
function ImportDefaultSpecifier(node) {
|
||||
this.print(node.local, node);
|
||||
}
|
||||
|
||||
function ExportDefaultSpecifier(node) {
|
||||
this.print(node.exported, node);
|
||||
}
|
||||
|
||||
function ExportSpecifier(node) {
|
||||
if (node.exportKind === "type") {
|
||||
this.word("type");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.local, node);
|
||||
|
||||
if (node.exported && node.local.name !== node.exported.name) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
@@ -65,7 +56,6 @@ function ExportSpecifier(node) {
|
||||
this.print(node.exported, node);
|
||||
}
|
||||
}
|
||||
|
||||
function ExportNamespaceSpecifier(node) {
|
||||
this.tokenChar(42);
|
||||
this.space();
|
||||
@@ -73,37 +63,36 @@ function ExportNamespaceSpecifier(node) {
|
||||
this.space();
|
||||
this.print(node.exported, node);
|
||||
}
|
||||
|
||||
function _printAssertions(node) {
|
||||
this.word("assert");
|
||||
this.space();
|
||||
this.tokenChar(123);
|
||||
this.space();
|
||||
this.printList(node.assertions, node);
|
||||
this.space();
|
||||
this.tokenChar(125);
|
||||
}
|
||||
function ExportAllDeclaration(node) {
|
||||
var _node$assertions;
|
||||
|
||||
this.word("export");
|
||||
this.space();
|
||||
|
||||
if (node.exportKind === "type") {
|
||||
this.word("type");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.tokenChar(42);
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
|
||||
if ((_node$assertions = node.assertions) != null && _node$assertions.length) {
|
||||
this.ensureNoLineTerminator(() => {
|
||||
this.print(node.source, node);
|
||||
this.space();
|
||||
this.word("assert");
|
||||
});
|
||||
this.printAssertions(node);
|
||||
this.print(node.source, node, true);
|
||||
this.space();
|
||||
this._printAssertions(node);
|
||||
} else {
|
||||
this.print(node.source, node);
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function ExportNamedDeclaration(node) {
|
||||
{
|
||||
if (this.format.decoratorsBeforeExport && isClassDeclaration(node.declaration)) {
|
||||
@@ -112,7 +101,6 @@ function ExportNamedDeclaration(node) {
|
||||
}
|
||||
this.word("export");
|
||||
this.space();
|
||||
|
||||
if (node.declaration) {
|
||||
const declar = node.declaration;
|
||||
this.print(declar, node);
|
||||
@@ -122,17 +110,14 @@ function ExportNamedDeclaration(node) {
|
||||
this.word("type");
|
||||
this.space();
|
||||
}
|
||||
|
||||
const specifiers = node.specifiers.slice(0);
|
||||
let hasSpecial = false;
|
||||
|
||||
let hasSpecial = false;
|
||||
for (;;) {
|
||||
const first = specifiers[0];
|
||||
|
||||
if (isExportDefaultSpecifier(first) || isExportNamespaceSpecifier(first)) {
|
||||
hasSpecial = true;
|
||||
this.print(specifiers.shift(), node);
|
||||
|
||||
if (specifiers.length) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
@@ -141,42 +126,31 @@ function ExportNamedDeclaration(node) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (specifiers.length || !specifiers.length && !hasSpecial) {
|
||||
this.tokenChar(123);
|
||||
|
||||
if (specifiers.length) {
|
||||
this.space();
|
||||
this.printList(specifiers, node);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
if (node.source) {
|
||||
var _node$assertions2;
|
||||
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
|
||||
if ((_node$assertions2 = node.assertions) != null && _node$assertions2.length) {
|
||||
this.ensureNoLineTerminator(() => {
|
||||
this.print(node.source, node);
|
||||
this.space();
|
||||
this.word("assert");
|
||||
});
|
||||
this.printAssertions(node);
|
||||
this.print(node.source, node, true);
|
||||
this.space();
|
||||
this._printAssertions(node);
|
||||
} else {
|
||||
this.print(node.source, node);
|
||||
}
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
}
|
||||
|
||||
function ExportDefaultDeclaration(node) {
|
||||
{
|
||||
if (this.format.decoratorsBeforeExport && isClassDeclaration(node.declaration)) {
|
||||
@@ -184,7 +158,7 @@ function ExportDefaultDeclaration(node) {
|
||||
}
|
||||
}
|
||||
this.word("export");
|
||||
this.printInnerComments(node);
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.space();
|
||||
this.word("default");
|
||||
this.space();
|
||||
@@ -192,33 +166,26 @@ function ExportDefaultDeclaration(node) {
|
||||
this.print(declar, node);
|
||||
if (!isStatement(declar)) this.semicolon();
|
||||
}
|
||||
|
||||
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.noIndentInnerCommentsHere();
|
||||
this.word(node.importKind);
|
||||
this.space();
|
||||
} else if (node.module) {
|
||||
this.printInnerComments(node, false);
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.word("module");
|
||||
this.space();
|
||||
}
|
||||
|
||||
const specifiers = node.specifiers.slice(0);
|
||||
const hasSpecifiers = !!specifiers.length;
|
||||
|
||||
while (hasSpecifiers) {
|
||||
const first = specifiers[0];
|
||||
|
||||
if (isImportDefaultSpecifier(first) || isImportNamespaceSpecifier(first)) {
|
||||
this.print(specifiers.shift(), node);
|
||||
|
||||
if (specifiers.length) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
@@ -227,7 +194,6 @@ function ImportDeclaration(node) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (specifiers.length) {
|
||||
this.tokenChar(123);
|
||||
this.space();
|
||||
@@ -238,27 +204,20 @@ function ImportDeclaration(node) {
|
||||
this.tokenChar(123);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
if (hasSpecifiers || isTypeKind) {
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
}
|
||||
|
||||
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);
|
||||
this.space();
|
||||
this._printAssertions(node);
|
||||
} else {
|
||||
this.print(node.source, node);
|
||||
}
|
||||
|
||||
{
|
||||
var _node$attributes;
|
||||
|
||||
if ((_node$attributes = node.attributes) != null && _node$attributes.length) {
|
||||
this.space();
|
||||
this.word("with");
|
||||
@@ -268,14 +227,12 @@ function ImportDeclaration(node) {
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function ImportAttribute(node) {
|
||||
this.print(node.key);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.value);
|
||||
}
|
||||
|
||||
function ImportNamespaceSpecifier(node) {
|
||||
this.tokenChar(42);
|
||||
this.space();
|
||||
|
||||
69
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/statements.js
generated
vendored
69
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/statements.js
generated
vendored
@@ -21,16 +21,13 @@ exports.VariableDeclaration = VariableDeclaration;
|
||||
exports.VariableDeclarator = VariableDeclarator;
|
||||
exports.WhileStatement = WhileStatement;
|
||||
exports.WithStatement = WithStatement;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
isFor,
|
||||
isForStatement,
|
||||
isIfStatement,
|
||||
isStatement
|
||||
} = _t;
|
||||
|
||||
function WithStatement(node) {
|
||||
this.word("with");
|
||||
this.space();
|
||||
@@ -39,7 +36,6 @@ function WithStatement(node) {
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
|
||||
function IfStatement(node) {
|
||||
this.word("if");
|
||||
this.space();
|
||||
@@ -48,21 +44,17 @@ function IfStatement(node) {
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
const needsBlock = node.alternate && isIfStatement(getLastStatement(node.consequent));
|
||||
|
||||
if (needsBlock) {
|
||||
this.tokenChar(123);
|
||||
this.newline();
|
||||
this.indent();
|
||||
}
|
||||
|
||||
this.printAndIndentOnComments(node.consequent, node);
|
||||
|
||||
if (needsBlock) {
|
||||
this.dedent();
|
||||
this.newline();
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
if (node.alternate) {
|
||||
if (this.endsWith(125)) this.space();
|
||||
this.word("else");
|
||||
@@ -75,14 +67,11 @@ function getLastStatement(statement) {
|
||||
const {
|
||||
body
|
||||
} = statement;
|
||||
|
||||
if (isStatement(body) === false) {
|
||||
return statement;
|
||||
}
|
||||
|
||||
return getLastStatement(body);
|
||||
}
|
||||
|
||||
function ForStatement(node) {
|
||||
this.word("for");
|
||||
this.space();
|
||||
@@ -91,23 +80,18 @@ function ForStatement(node) {
|
||||
this.print(node.init, node);
|
||||
this.inForStatementInitCounter--;
|
||||
this.tokenChar(59);
|
||||
|
||||
if (node.test) {
|
||||
this.space();
|
||||
this.print(node.test, node);
|
||||
}
|
||||
|
||||
this.tokenChar(59);
|
||||
|
||||
if (node.update) {
|
||||
this.space();
|
||||
this.print(node.update, node);
|
||||
}
|
||||
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
|
||||
function WhileStatement(node) {
|
||||
this.word("while");
|
||||
this.space();
|
||||
@@ -116,18 +100,15 @@ function WhileStatement(node) {
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
|
||||
function ForXStatement(node) {
|
||||
this.word("for");
|
||||
this.space();
|
||||
const isForOf = node.type === "ForOfStatement";
|
||||
|
||||
if (isForOf && node.await) {
|
||||
this.word("await");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.printInnerComments(node, false);
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.tokenChar(40);
|
||||
this.print(node.left, node);
|
||||
this.space();
|
||||
@@ -137,12 +118,10 @@ function ForXStatement(node) {
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
|
||||
const ForInStatement = ForXStatement;
|
||||
exports.ForInStatement = ForInStatement;
|
||||
const ForOfStatement = ForXStatement;
|
||||
exports.ForOfStatement = ForOfStatement;
|
||||
|
||||
function DoWhileStatement(node) {
|
||||
this.word("do");
|
||||
this.space();
|
||||
@@ -155,43 +134,35 @@ function DoWhileStatement(node) {
|
||||
this.tokenChar(41);
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function printStatementAfterKeyword(printer, node, parent, isLabel) {
|
||||
if (node) {
|
||||
printer.space();
|
||||
printer.printTerminatorless(node, parent, isLabel);
|
||||
}
|
||||
|
||||
printer.semicolon();
|
||||
}
|
||||
|
||||
function BreakStatement(node) {
|
||||
this.word("break");
|
||||
printStatementAfterKeyword(this, node.label, node, true);
|
||||
}
|
||||
|
||||
function ContinueStatement(node) {
|
||||
this.word("continue");
|
||||
printStatementAfterKeyword(this, node.label, node, true);
|
||||
}
|
||||
|
||||
function ReturnStatement(node) {
|
||||
this.word("return");
|
||||
printStatementAfterKeyword(this, node.argument, node, false);
|
||||
}
|
||||
|
||||
function ThrowStatement(node) {
|
||||
this.word("throw");
|
||||
printStatementAfterKeyword(this, node.argument, node, false);
|
||||
}
|
||||
|
||||
function LabeledStatement(node) {
|
||||
this.print(node.label, node);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function TryStatement(node) {
|
||||
this.word("try");
|
||||
this.space();
|
||||
@@ -203,7 +174,6 @@ function TryStatement(node) {
|
||||
} else {
|
||||
this.print(node.handler, node);
|
||||
}
|
||||
|
||||
if (node.finalizer) {
|
||||
this.space();
|
||||
this.word("finally");
|
||||
@@ -211,11 +181,9 @@ function TryStatement(node) {
|
||||
this.print(node.finalizer, node);
|
||||
}
|
||||
}
|
||||
|
||||
function CatchClause(node) {
|
||||
this.word("catch");
|
||||
this.space();
|
||||
|
||||
if (node.param) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.param, node);
|
||||
@@ -223,10 +191,8 @@ function CatchClause(node) {
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function SwitchStatement(node) {
|
||||
this.word("switch");
|
||||
this.space();
|
||||
@@ -237,15 +203,12 @@ function SwitchStatement(node) {
|
||||
this.tokenChar(123);
|
||||
this.printSequence(node.cases, node, {
|
||||
indent: true,
|
||||
|
||||
addNewlines(leading, cas) {
|
||||
if (!leading && node.cases[node.cases.length - 1] === cas) return -1;
|
||||
}
|
||||
|
||||
});
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
function SwitchCase(node) {
|
||||
if (node.test) {
|
||||
this.word("case");
|
||||
@@ -256,7 +219,6 @@ function SwitchCase(node) {
|
||||
this.word("default");
|
||||
this.tokenChar(58);
|
||||
}
|
||||
|
||||
if (node.consequent.length) {
|
||||
this.newline();
|
||||
this.printSequence(node.consequent, node, {
|
||||
@@ -264,33 +226,21 @@ function SwitchCase(node) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function DebuggerStatement() {
|
||||
this.word("debugger");
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function VariableDeclaration(node, parent) {
|
||||
if (node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
const {
|
||||
kind
|
||||
} = node;
|
||||
this.word(kind);
|
||||
const {
|
||||
_noLineTerminator
|
||||
} = this;
|
||||
|
||||
if (kind === "using") {
|
||||
this._noLineTerminator = true;
|
||||
}
|
||||
|
||||
this.word(kind, kind === "using");
|
||||
this.space();
|
||||
let hasInits = false;
|
||||
|
||||
if (!isFor(parent)) {
|
||||
for (const declar of node.declarations) {
|
||||
if (declar.init) {
|
||||
@@ -299,25 +249,13 @@ function VariableDeclaration(node, parent) {
|
||||
}
|
||||
}
|
||||
|
||||
let iterator;
|
||||
|
||||
if (kind === "using") {
|
||||
iterator = (_, i) => {
|
||||
if (i === 0) {
|
||||
this._noLineTerminator = _noLineTerminator;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
this.printList(node.declarations, node, {
|
||||
separator: hasInits ? function () {
|
||||
this.tokenChar(44);
|
||||
this.newline();
|
||||
} : undefined,
|
||||
iterator,
|
||||
indent: node.declarations.length > 1 ? true : false
|
||||
});
|
||||
|
||||
if (isFor(parent)) {
|
||||
if (isForStatement(parent)) {
|
||||
if (parent.init === node) return;
|
||||
@@ -325,15 +263,12 @@ function VariableDeclaration(node, parent) {
|
||||
if (parent.left === node) return;
|
||||
}
|
||||
}
|
||||
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
function VariableDeclarator(node) {
|
||||
this.print(node.id, node);
|
||||
if (node.definite) this.tokenChar(33);
|
||||
this.print(node.id.typeAnnotation, node);
|
||||
|
||||
if (node.init) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
|
||||
@@ -6,26 +6,21 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.TaggedTemplateExpression = TaggedTemplateExpression;
|
||||
exports.TemplateElement = TemplateElement;
|
||||
exports.TemplateLiteral = TemplateLiteral;
|
||||
|
||||
function TaggedTemplateExpression(node) {
|
||||
this.print(node.tag, node);
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.quasi, node);
|
||||
}
|
||||
|
||||
function TemplateElement(node, parent) {
|
||||
const isFirst = parent.quasis[0] === node;
|
||||
const isLast = parent.quasis[parent.quasis.length - 1] === node;
|
||||
const value = (isFirst ? "`" : "}") + node.value.raw + (isLast ? "`" : "${");
|
||||
this.token(value, true);
|
||||
}
|
||||
|
||||
function TemplateLiteral(node) {
|
||||
const quasis = node.quasis;
|
||||
|
||||
for (let i = 0; i < quasis.length; i++) {
|
||||
this.print(quasis[i], node);
|
||||
|
||||
if (i + 1 < quasis.length) {
|
||||
this.print(node.expressions[i], node);
|
||||
}
|
||||
|
||||
57
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/types.js
generated
vendored
57
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/types.js
generated
vendored
@@ -23,34 +23,25 @@ exports.SpreadElement = exports.RestElement = RestElement;
|
||||
exports.StringLiteral = StringLiteral;
|
||||
exports.TopicReference = TopicReference;
|
||||
exports.TupleExpression = TupleExpression;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var _jsesc = require("jsesc");
|
||||
|
||||
const {
|
||||
isAssignmentPattern,
|
||||
isIdentifier
|
||||
} = _t;
|
||||
|
||||
function Identifier(node) {
|
||||
this.word(node.name);
|
||||
}
|
||||
|
||||
function ArgumentPlaceholder() {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
|
||||
function RestElement(node) {
|
||||
this.token("...");
|
||||
this.print(node.argument, node);
|
||||
}
|
||||
|
||||
function ObjectExpression(node) {
|
||||
const props = node.properties;
|
||||
this.tokenChar(123);
|
||||
this.printInnerComments(node);
|
||||
|
||||
if (props.length) {
|
||||
this.space();
|
||||
this.printList(props, node, {
|
||||
@@ -59,54 +50,43 @@ function ObjectExpression(node) {
|
||||
});
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.sourceWithOffset("end", node.loc, 0, -1);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
function ObjectMethod(node) {
|
||||
this.printJoin(node.decorators, node);
|
||||
|
||||
this._methodHead(node);
|
||||
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
}
|
||||
|
||||
function ObjectProperty(node) {
|
||||
this.printJoin(node.decorators, node);
|
||||
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.key, node);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
if (isAssignmentPattern(node.value) && isIdentifier(node.key) && node.key.name === node.value.left.name) {
|
||||
if (isAssignmentPattern(node.value) && isIdentifier(node.key) &&
|
||||
node.key.name === node.value.left.name) {
|
||||
this.print(node.value, node);
|
||||
return;
|
||||
}
|
||||
|
||||
this.print(node.key, node);
|
||||
|
||||
if (node.shorthand && isIdentifier(node.key) && isIdentifier(node.value) && node.key.name === node.value.name) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
}
|
||||
|
||||
function ArrayExpression(node) {
|
||||
const elems = node.elements;
|
||||
const len = elems.length;
|
||||
this.tokenChar(91);
|
||||
this.printInnerComments(node);
|
||||
|
||||
for (let i = 0; i < elems.length; i++) {
|
||||
const elem = elems[i];
|
||||
|
||||
if (elem) {
|
||||
if (i > 0) this.space();
|
||||
this.print(elem, node);
|
||||
@@ -115,15 +95,12 @@ function ArrayExpression(node) {
|
||||
this.tokenChar(44);
|
||||
}
|
||||
}
|
||||
|
||||
this.tokenChar(93);
|
||||
}
|
||||
|
||||
function RecordExpression(node) {
|
||||
const props = node.properties;
|
||||
let startToken;
|
||||
let endToken;
|
||||
|
||||
if (this.format.recordAndTupleSyntaxType === "bar") {
|
||||
startToken = "{|";
|
||||
endToken = "|}";
|
||||
@@ -133,10 +110,7 @@ function RecordExpression(node) {
|
||||
startToken = "#{";
|
||||
endToken = "}";
|
||||
}
|
||||
|
||||
this.token(startToken);
|
||||
this.printInnerComments(node);
|
||||
|
||||
if (props.length) {
|
||||
this.space();
|
||||
this.printList(props, node, {
|
||||
@@ -145,16 +119,13 @@ function RecordExpression(node) {
|
||||
});
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.token(endToken);
|
||||
}
|
||||
|
||||
function TupleExpression(node) {
|
||||
const elems = node.elements;
|
||||
const len = elems.length;
|
||||
let startToken;
|
||||
let endToken;
|
||||
|
||||
if (this.format.recordAndTupleSyntaxType === "bar") {
|
||||
startToken = "[|";
|
||||
endToken = "|]";
|
||||
@@ -164,40 +135,30 @@ function TupleExpression(node) {
|
||||
} else {
|
||||
throw new Error(`${this.format.recordAndTupleSyntaxType} is not a valid recordAndTuple syntax type`);
|
||||
}
|
||||
|
||||
this.token(startToken);
|
||||
this.printInnerComments(node);
|
||||
|
||||
for (let i = 0; i < elems.length; i++) {
|
||||
const elem = elems[i];
|
||||
|
||||
if (elem) {
|
||||
if (i > 0) this.space();
|
||||
this.print(elem, node);
|
||||
if (i < len - 1) this.tokenChar(44);
|
||||
}
|
||||
}
|
||||
|
||||
this.token(endToken);
|
||||
}
|
||||
|
||||
function RegExpLiteral(node) {
|
||||
this.word(`/${node.pattern}/${node.flags}`);
|
||||
}
|
||||
|
||||
function BooleanLiteral(node) {
|
||||
this.word(node.value ? "true" : "false");
|
||||
}
|
||||
|
||||
function NullLiteral() {
|
||||
this.word("null");
|
||||
}
|
||||
|
||||
function NumericLiteral(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
const opts = this.format.jsescOption;
|
||||
const value = node.value + "";
|
||||
|
||||
if (opts.numbers) {
|
||||
this.number(_jsesc(node.value, opts));
|
||||
} else if (raw == null) {
|
||||
@@ -208,51 +169,39 @@ function NumericLiteral(node) {
|
||||
this.number(raw);
|
||||
}
|
||||
}
|
||||
|
||||
function StringLiteral(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
|
||||
if (!this.format.minified && raw !== undefined) {
|
||||
this.token(raw);
|
||||
return;
|
||||
}
|
||||
|
||||
const val = _jsesc(node.value, Object.assign(this.format.jsescOption, this.format.jsonCompatibleStrings && {
|
||||
json: true
|
||||
}));
|
||||
|
||||
return this.token(val);
|
||||
}
|
||||
|
||||
function BigIntLiteral(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
|
||||
if (!this.format.minified && raw !== undefined) {
|
||||
this.word(raw);
|
||||
return;
|
||||
}
|
||||
|
||||
this.word(node.value + "n");
|
||||
}
|
||||
|
||||
function DecimalLiteral(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
|
||||
if (!this.format.minified && raw !== undefined) {
|
||||
this.word(raw);
|
||||
return;
|
||||
}
|
||||
|
||||
this.word(node.value + "m");
|
||||
}
|
||||
|
||||
const validTopicTokenSet = new Set(["^^", "@@", "^", "%", "#"]);
|
||||
|
||||
function TopicReference() {
|
||||
const {
|
||||
topicToken
|
||||
} = this.format;
|
||||
|
||||
if (validTopicTokenSet.has(topicToken)) {
|
||||
this.token(topicToken);
|
||||
} else {
|
||||
@@ -265,11 +214,9 @@ function TopicReference() {
|
||||
function PipelineTopicExpression(node) {
|
||||
this.print(node.expression, node);
|
||||
}
|
||||
|
||||
function PipelineBareFunction(node) {
|
||||
this.print(node.callee, node);
|
||||
}
|
||||
|
||||
function PipelinePrimaryTopicReference() {
|
||||
this.tokenChar(35);
|
||||
}
|
||||
|
||||
150
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/typescript.js
generated
vendored
150
tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/typescript.js
generated
vendored
@@ -71,45 +71,36 @@ exports.tsPrintFunctionOrConstructorType = tsPrintFunctionOrConstructorType;
|
||||
exports.tsPrintPropertyOrMethodName = tsPrintPropertyOrMethodName;
|
||||
exports.tsPrintSignatureDeclarationBase = tsPrintSignatureDeclarationBase;
|
||||
exports.tsPrintTypeLiteralOrInterfaceBody = tsPrintTypeLiteralOrInterfaceBody;
|
||||
|
||||
function TSTypeAnnotation(node) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
if (node.optional) this.tokenChar(63);
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
function TSTypeParameterInstantiation(node, parent) {
|
||||
this.tokenChar(60);
|
||||
this.printList(node.params, node, {});
|
||||
|
||||
if (parent.type === "ArrowFunctionExpression" && node.params.length === 1) {
|
||||
this.tokenChar(44);
|
||||
}
|
||||
|
||||
this.tokenChar(62);
|
||||
}
|
||||
|
||||
function TSTypeParameter(node) {
|
||||
if (node.in) {
|
||||
this.word("in");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.out) {
|
||||
this.word("out");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word(node.name);
|
||||
|
||||
if (node.constraint) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.print(node.constraint, node);
|
||||
}
|
||||
|
||||
if (node.default) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
@@ -117,238 +108,187 @@ function TSTypeParameter(node) {
|
||||
this.print(node.default, node);
|
||||
}
|
||||
}
|
||||
|
||||
function TSParameterProperty(node) {
|
||||
if (node.accessibility) {
|
||||
this.word(node.accessibility);
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this._param(node.parameter);
|
||||
}
|
||||
|
||||
function TSDeclareFunction(node) {
|
||||
if (node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this._functionHead(node);
|
||||
|
||||
this.tokenChar(59);
|
||||
}
|
||||
|
||||
function TSDeclareMethod(node) {
|
||||
this._classMethodHead(node);
|
||||
|
||||
this.tokenChar(59);
|
||||
}
|
||||
|
||||
function TSQualifiedName(node) {
|
||||
this.print(node.left, node);
|
||||
this.tokenChar(46);
|
||||
this.print(node.right, node);
|
||||
}
|
||||
|
||||
function TSCallSignatureDeclaration(node) {
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
this.tokenChar(59);
|
||||
}
|
||||
|
||||
function TSConstructSignatureDeclaration(node) {
|
||||
this.word("new");
|
||||
this.space();
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
this.tokenChar(59);
|
||||
}
|
||||
|
||||
function TSPropertySignature(node) {
|
||||
const {
|
||||
readonly,
|
||||
initializer
|
||||
} = node;
|
||||
|
||||
if (readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.tsPrintPropertyOrMethodName(node);
|
||||
this.print(node.typeAnnotation, node);
|
||||
|
||||
if (initializer) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(initializer, node);
|
||||
}
|
||||
|
||||
this.tokenChar(59);
|
||||
}
|
||||
|
||||
function tsPrintPropertyOrMethodName(node) {
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
}
|
||||
|
||||
this.print(node.key, node);
|
||||
|
||||
if (node.computed) {
|
||||
this.tokenChar(93);
|
||||
}
|
||||
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
}
|
||||
|
||||
function TSMethodSignature(node) {
|
||||
const {
|
||||
kind
|
||||
} = node;
|
||||
|
||||
if (kind === "set" || kind === "get") {
|
||||
this.word(kind);
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.tsPrintPropertyOrMethodName(node);
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
this.tokenChar(59);
|
||||
}
|
||||
|
||||
function TSIndexSignature(node) {
|
||||
const {
|
||||
readonly,
|
||||
static: isStatic
|
||||
} = node;
|
||||
|
||||
if (isStatic) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.tokenChar(91);
|
||||
|
||||
this._parameters(node.parameters, node);
|
||||
|
||||
this.tokenChar(93);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.tokenChar(59);
|
||||
}
|
||||
|
||||
function TSAnyKeyword() {
|
||||
this.word("any");
|
||||
}
|
||||
|
||||
function TSBigIntKeyword() {
|
||||
this.word("bigint");
|
||||
}
|
||||
|
||||
function TSUnknownKeyword() {
|
||||
this.word("unknown");
|
||||
}
|
||||
|
||||
function TSNumberKeyword() {
|
||||
this.word("number");
|
||||
}
|
||||
|
||||
function TSObjectKeyword() {
|
||||
this.word("object");
|
||||
}
|
||||
|
||||
function TSBooleanKeyword() {
|
||||
this.word("boolean");
|
||||
}
|
||||
|
||||
function TSStringKeyword() {
|
||||
this.word("string");
|
||||
}
|
||||
|
||||
function TSSymbolKeyword() {
|
||||
this.word("symbol");
|
||||
}
|
||||
|
||||
function TSVoidKeyword() {
|
||||
this.word("void");
|
||||
}
|
||||
|
||||
function TSUndefinedKeyword() {
|
||||
this.word("undefined");
|
||||
}
|
||||
|
||||
function TSNullKeyword() {
|
||||
this.word("null");
|
||||
}
|
||||
|
||||
function TSNeverKeyword() {
|
||||
this.word("never");
|
||||
}
|
||||
|
||||
function TSIntrinsicKeyword() {
|
||||
this.word("intrinsic");
|
||||
}
|
||||
|
||||
function TSThisType() {
|
||||
this.word("this");
|
||||
}
|
||||
|
||||
function TSFunctionType(node) {
|
||||
this.tsPrintFunctionOrConstructorType(node);
|
||||
}
|
||||
|
||||
function TSConstructorType(node) {
|
||||
if (node.abstract) {
|
||||
this.word("abstract");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("new");
|
||||
this.space();
|
||||
this.tsPrintFunctionOrConstructorType(node);
|
||||
}
|
||||
|
||||
function tsPrintFunctionOrConstructorType(node) {
|
||||
const {
|
||||
typeParameters
|
||||
} = node;
|
||||
const parameters = node.parameters;
|
||||
const parameters =
|
||||
node.parameters;
|
||||
this.print(typeParameters, node);
|
||||
this.tokenChar(40);
|
||||
|
||||
this._parameters(parameters, node);
|
||||
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
this.token("=>");
|
||||
this.space();
|
||||
const returnType = node.typeAnnotation;
|
||||
const returnType =
|
||||
node.typeAnnotation;
|
||||
this.print(returnType.typeAnnotation, node);
|
||||
}
|
||||
|
||||
function TSTypeReference(node) {
|
||||
this.print(node.typeName, node, true);
|
||||
this.print(node.typeParameters, node, true);
|
||||
}
|
||||
|
||||
function TSTypePredicate(node) {
|
||||
if (node.asserts) {
|
||||
this.word("asserts");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node.parameterName);
|
||||
|
||||
if (node.typeAnnotation) {
|
||||
this.space();
|
||||
this.word("is");
|
||||
@@ -356,65 +296,51 @@ function TSTypePredicate(node) {
|
||||
this.print(node.typeAnnotation.typeAnnotation);
|
||||
}
|
||||
}
|
||||
|
||||
function TSTypeQuery(node) {
|
||||
this.word("typeof");
|
||||
this.space();
|
||||
this.print(node.exprName);
|
||||
|
||||
if (node.typeParameters) {
|
||||
this.print(node.typeParameters, node);
|
||||
}
|
||||
}
|
||||
|
||||
function TSTypeLiteral(node) {
|
||||
this.tsPrintTypeLiteralOrInterfaceBody(node.members, node);
|
||||
}
|
||||
|
||||
function tsPrintTypeLiteralOrInterfaceBody(members, node) {
|
||||
tsPrintBraced(this, members, node);
|
||||
}
|
||||
|
||||
function tsPrintBraced(printer, members, node) {
|
||||
printer.token("{");
|
||||
|
||||
if (members.length) {
|
||||
printer.indent();
|
||||
printer.newline();
|
||||
|
||||
for (const member of members) {
|
||||
printer.print(member, node);
|
||||
printer.newline();
|
||||
}
|
||||
|
||||
printer.dedent();
|
||||
}
|
||||
|
||||
printer.sourceWithOffset("end", node.loc, 0, -1);
|
||||
printer.rightBrace();
|
||||
}
|
||||
|
||||
function TSArrayType(node) {
|
||||
this.print(node.elementType, node, true);
|
||||
this.token("[]");
|
||||
}
|
||||
|
||||
function TSTupleType(node) {
|
||||
this.tokenChar(91);
|
||||
this.printList(node.elementTypes, node);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
|
||||
function TSOptionalType(node) {
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.tokenChar(63);
|
||||
}
|
||||
|
||||
function TSRestType(node) {
|
||||
this.token("...");
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
function TSNamedTupleMember(node) {
|
||||
this.print(node.label, node);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
@@ -422,15 +348,12 @@ function TSNamedTupleMember(node) {
|
||||
this.space();
|
||||
this.print(node.elementType, node);
|
||||
}
|
||||
|
||||
function TSUnionType(node) {
|
||||
tsPrintUnionOrIntersectionType(this, node, "|");
|
||||
}
|
||||
|
||||
function TSIntersectionType(node) {
|
||||
tsPrintUnionOrIntersectionType(this, node, "&");
|
||||
}
|
||||
|
||||
function tsPrintUnionOrIntersectionType(printer, node, sep) {
|
||||
printer.printJoin(node.types, node, {
|
||||
separator() {
|
||||
@@ -438,10 +361,8 @@ function tsPrintUnionOrIntersectionType(printer, node, sep) {
|
||||
this.token(sep);
|
||||
this.space();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function TSConditionalType(node) {
|
||||
this.print(node.checkType);
|
||||
this.space();
|
||||
@@ -457,32 +378,27 @@ function TSConditionalType(node) {
|
||||
this.space();
|
||||
this.print(node.falseType);
|
||||
}
|
||||
|
||||
function TSInferType(node) {
|
||||
this.token("infer");
|
||||
this.space();
|
||||
this.print(node.typeParameter);
|
||||
}
|
||||
|
||||
function TSParenthesizedType(node) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
|
||||
function TSTypeOperator(node) {
|
||||
this.word(node.operator);
|
||||
this.space();
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
function TSIndexedAccessType(node) {
|
||||
this.print(node.objectType, node, true);
|
||||
this.tokenChar(91);
|
||||
this.print(node.indexType, node);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
|
||||
function TSMappedType(node) {
|
||||
const {
|
||||
nameType,
|
||||
@@ -492,56 +408,46 @@ function TSMappedType(node) {
|
||||
} = node;
|
||||
this.tokenChar(123);
|
||||
this.space();
|
||||
|
||||
if (readonly) {
|
||||
tokenIfPlusMinus(this, readonly);
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.tokenChar(91);
|
||||
this.word(typeParameter.name);
|
||||
this.space();
|
||||
this.word("in");
|
||||
this.space();
|
||||
this.print(typeParameter.constraint, typeParameter);
|
||||
|
||||
if (nameType) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(nameType, node);
|
||||
}
|
||||
|
||||
this.tokenChar(93);
|
||||
|
||||
if (optional) {
|
||||
tokenIfPlusMinus(this, optional);
|
||||
this.tokenChar(63);
|
||||
}
|
||||
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.space();
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
function tokenIfPlusMinus(self, tok) {
|
||||
if (tok !== true) {
|
||||
self.token(tok);
|
||||
}
|
||||
}
|
||||
|
||||
function TSLiteralType(node) {
|
||||
this.print(node.literal, node);
|
||||
}
|
||||
|
||||
function TSExpressionWithTypeArguments(node) {
|
||||
this.print(node.expression, node);
|
||||
this.print(node.typeParameters, node);
|
||||
}
|
||||
|
||||
function TSInterfaceDeclaration(node) {
|
||||
const {
|
||||
declare,
|
||||
@@ -550,32 +456,26 @@ function TSInterfaceDeclaration(node) {
|
||||
extends: extendz,
|
||||
body
|
||||
} = node;
|
||||
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("interface");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.print(typeParameters, node);
|
||||
|
||||
if (extendz != null && extendz.length) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(extendz, node);
|
||||
}
|
||||
|
||||
this.space();
|
||||
this.print(body, node);
|
||||
}
|
||||
|
||||
function TSInterfaceBody(node) {
|
||||
this.tsPrintTypeLiteralOrInterfaceBody(node.body, node);
|
||||
}
|
||||
|
||||
function TSTypeAliasDeclaration(node) {
|
||||
const {
|
||||
declare,
|
||||
@@ -583,12 +483,10 @@ function TSTypeAliasDeclaration(node) {
|
||||
typeParameters,
|
||||
typeAnnotation
|
||||
} = node;
|
||||
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("type");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
@@ -599,10 +497,8 @@ function TSTypeAliasDeclaration(node) {
|
||||
this.print(typeAnnotation, node);
|
||||
this.tokenChar(59);
|
||||
}
|
||||
|
||||
function TSTypeExpression(node) {
|
||||
var _expression$trailingC;
|
||||
|
||||
const {
|
||||
type,
|
||||
expression,
|
||||
@@ -615,7 +511,6 @@ function TSTypeExpression(node) {
|
||||
this.space();
|
||||
this.print(typeAnnotation, node);
|
||||
}
|
||||
|
||||
function TSTypeAssertion(node) {
|
||||
const {
|
||||
typeAnnotation,
|
||||
@@ -627,12 +522,10 @@ function TSTypeAssertion(node) {
|
||||
this.space();
|
||||
this.print(expression, node);
|
||||
}
|
||||
|
||||
function TSInstantiationExpression(node) {
|
||||
this.print(node.expression, node);
|
||||
this.print(node.typeParameters, node);
|
||||
}
|
||||
|
||||
function TSEnumDeclaration(node) {
|
||||
const {
|
||||
declare,
|
||||
@@ -640,80 +533,64 @@ function TSEnumDeclaration(node) {
|
||||
id,
|
||||
members
|
||||
} = node;
|
||||
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (isConst) {
|
||||
this.word("const");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("enum");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.space();
|
||||
tsPrintBraced(this, members, node);
|
||||
}
|
||||
|
||||
function TSEnumMember(node) {
|
||||
const {
|
||||
id,
|
||||
initializer
|
||||
} = node;
|
||||
this.print(id, node);
|
||||
|
||||
if (initializer) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(initializer, node);
|
||||
}
|
||||
|
||||
this.tokenChar(44);
|
||||
}
|
||||
|
||||
function TSModuleDeclaration(node) {
|
||||
const {
|
||||
declare,
|
||||
id
|
||||
} = node;
|
||||
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (!node.global) {
|
||||
this.word(id.type === "Identifier" ? "namespace" : "module");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(id, node);
|
||||
|
||||
if (!node.body) {
|
||||
this.tokenChar(59);
|
||||
return;
|
||||
}
|
||||
|
||||
let body = node.body;
|
||||
|
||||
while (body.type === "TSModuleDeclaration") {
|
||||
this.tokenChar(46);
|
||||
this.print(body.id, body);
|
||||
body = body.body;
|
||||
}
|
||||
|
||||
this.space();
|
||||
this.print(body, node);
|
||||
}
|
||||
|
||||
function TSModuleBlock(node) {
|
||||
tsPrintBraced(this, node.body, node);
|
||||
}
|
||||
|
||||
function TSImportType(node) {
|
||||
const {
|
||||
argument,
|
||||
@@ -724,29 +601,24 @@ function TSImportType(node) {
|
||||
this.tokenChar(40);
|
||||
this.print(argument, node);
|
||||
this.tokenChar(41);
|
||||
|
||||
if (qualifier) {
|
||||
this.tokenChar(46);
|
||||
this.print(qualifier, node);
|
||||
}
|
||||
|
||||
if (typeParameters) {
|
||||
this.print(typeParameters, node);
|
||||
}
|
||||
}
|
||||
|
||||
function TSImportEqualsDeclaration(node) {
|
||||
const {
|
||||
isExport,
|
||||
id,
|
||||
moduleReference
|
||||
} = node;
|
||||
|
||||
if (isExport) {
|
||||
this.word("export");
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.word("import");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
@@ -756,18 +628,15 @@ function TSImportEqualsDeclaration(node) {
|
||||
this.print(moduleReference, node);
|
||||
this.tokenChar(59);
|
||||
}
|
||||
|
||||
function TSExternalModuleReference(node) {
|
||||
this.token("require(");
|
||||
this.print(node.expression, node);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
|
||||
function TSNonNullExpression(node) {
|
||||
this.print(node.expression, node);
|
||||
this.tokenChar(33);
|
||||
}
|
||||
|
||||
function TSExportAssignment(node) {
|
||||
this.word("export");
|
||||
this.space();
|
||||
@@ -776,7 +645,6 @@ function TSExportAssignment(node) {
|
||||
this.print(node.expression, node);
|
||||
this.tokenChar(59);
|
||||
}
|
||||
|
||||
function TSNamespaceExportDeclaration(node) {
|
||||
this.word("export");
|
||||
this.space();
|
||||
@@ -786,7 +654,6 @@ function TSNamespaceExportDeclaration(node) {
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
}
|
||||
|
||||
function tsPrintSignatureDeclarationBase(node) {
|
||||
const {
|
||||
typeParameters
|
||||
@@ -794,42 +661,33 @@ function tsPrintSignatureDeclarationBase(node) {
|
||||
const parameters = node.parameters;
|
||||
this.print(typeParameters, node);
|
||||
this.tokenChar(40);
|
||||
|
||||
this._parameters(parameters, node);
|
||||
|
||||
this.tokenChar(41);
|
||||
const returnType = node.typeAnnotation;
|
||||
this.print(returnType, node);
|
||||
}
|
||||
|
||||
function tsPrintClassMemberModifiers(node) {
|
||||
const isField = node.type === "ClassAccessorProperty" || node.type === "ClassProperty";
|
||||
|
||||
if (isField && node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.accessibility) {
|
||||
this.word(node.accessibility);
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.override) {
|
||||
this.word("override");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.abstract) {
|
||||
this.word("abstract");
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (isField && node.readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
|
||||
11
tools/node_modules/eslint/node_modules/@babel/generator/lib/index.js
generated
vendored
11
tools/node_modules/eslint/node_modules/@babel/generator/lib/index.js
generated
vendored
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
exports.CodeGenerator = void 0;
|
||||
exports.default = generate;
|
||||
|
||||
var _sourceMap = require("./source-map");
|
||||
|
||||
var _printer = require("./printer");
|
||||
|
||||
class Generator extends _printer.default {
|
||||
@@ -22,7 +20,6 @@ class Generator extends _printer.default {
|
||||
generate() {
|
||||
return super.generate(this.ast);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function normalizeOptions(code, opts) {
|
||||
@@ -52,15 +49,12 @@ function normalizeOptions(code, opts) {
|
||||
format.decoratorsBeforeExport = !!opts.decoratorsBeforeExport;
|
||||
format.jsonCompatibleStrings = opts.jsonCompatibleStrings;
|
||||
}
|
||||
|
||||
if (format.minified) {
|
||||
format.compact = true;
|
||||
|
||||
format.shouldPrintComment = format.shouldPrintComment || (() => format.comments);
|
||||
} else {
|
||||
format.shouldPrintComment = format.shouldPrintComment || (value => format.comments || value.includes("@license") || value.includes("@preserve"));
|
||||
}
|
||||
|
||||
if (format.compact === "auto") {
|
||||
format.compact = code.length > 500000;
|
||||
|
||||
@@ -68,11 +62,9 @@ function normalizeOptions(code, opts) {
|
||||
console.error("[BABEL] Note: The code generator has deoptimised the styling of " + `${opts.filename} as it exceeds the max of ${"500KB"}.`);
|
||||
}
|
||||
}
|
||||
|
||||
if (format.compact) {
|
||||
format.indent.adjustMultilineComment = false;
|
||||
}
|
||||
|
||||
return format;
|
||||
}
|
||||
|
||||
@@ -81,15 +73,12 @@ class CodeGenerator {
|
||||
this._generator = void 0;
|
||||
this._generator = new Generator(ast, opts, code);
|
||||
}
|
||||
|
||||
generate() {
|
||||
return this._generator.generate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.CodeGenerator = CodeGenerator;
|
||||
|
||||
function generate(ast, opts, code) {
|
||||
const gen = new Generator(ast, opts, code);
|
||||
return gen.generate();
|
||||
|
||||
22
tools/node_modules/eslint/node_modules/@babel/generator/lib/node/index.js
generated
vendored
22
tools/node_modules/eslint/node_modules/@babel/generator/lib/node/index.js
generated
vendored
@@ -7,13 +7,9 @@ exports.needsParens = needsParens;
|
||||
exports.needsWhitespace = needsWhitespace;
|
||||
exports.needsWhitespaceAfter = needsWhitespaceAfter;
|
||||
exports.needsWhitespaceBefore = needsWhitespaceBefore;
|
||||
|
||||
var whitespace = require("./whitespace");
|
||||
|
||||
var parens = require("./parentheses");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
FLIPPED_ALIAS_KEYS,
|
||||
isCallExpression,
|
||||
@@ -21,10 +17,8 @@ const {
|
||||
isMemberExpression,
|
||||
isNewExpression
|
||||
} = _t;
|
||||
|
||||
function expandAliases(obj) {
|
||||
const newObj = {};
|
||||
|
||||
function add(type, func) {
|
||||
const fn = newObj[type];
|
||||
newObj[type] = fn ? function (node, parent, stack) {
|
||||
@@ -32,10 +26,8 @@ function expandAliases(obj) {
|
||||
return result == null ? func(node, parent, stack) : result;
|
||||
} : func;
|
||||
}
|
||||
|
||||
for (const type of Object.keys(obj)) {
|
||||
const aliases = FLIPPED_ALIAS_KEYS[type];
|
||||
|
||||
if (aliases) {
|
||||
for (const alias of aliases) {
|
||||
add(alias, obj[type]);
|
||||
@@ -44,57 +36,43 @@ function expandAliases(obj) {
|
||||
add(type, obj[type]);
|
||||
}
|
||||
}
|
||||
|
||||
return newObj;
|
||||
}
|
||||
|
||||
const expandedParens = expandAliases(parens);
|
||||
const expandedWhitespaceNodes = expandAliases(whitespace.nodes);
|
||||
|
||||
function find(obj, node, parent, printStack) {
|
||||
const fn = obj[node.type];
|
||||
return fn ? fn(node, parent, printStack) : null;
|
||||
}
|
||||
|
||||
function isOrHasCallExpression(node) {
|
||||
if (isCallExpression(node)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isMemberExpression(node) && isOrHasCallExpression(node.object);
|
||||
}
|
||||
|
||||
function needsWhitespace(node, parent, type) {
|
||||
if (!node) return false;
|
||||
|
||||
if (isExpressionStatement(node)) {
|
||||
node = node.expression;
|
||||
}
|
||||
|
||||
const flag = find(expandedWhitespaceNodes, node, parent);
|
||||
|
||||
if (typeof flag === "number") {
|
||||
return (flag & type) !== 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function needsWhitespaceBefore(node, parent) {
|
||||
return needsWhitespace(node, parent, 1);
|
||||
}
|
||||
|
||||
function needsWhitespaceAfter(node, parent) {
|
||||
return needsWhitespace(node, parent, 2);
|
||||
}
|
||||
|
||||
function needsParens(node, parent, printStack) {
|
||||
if (!parent) return false;
|
||||
|
||||
if (isNewExpression(parent) && parent.callee === node) {
|
||||
if (isOrHasCallExpression(node)) return true;
|
||||
}
|
||||
|
||||
return find(expandedParens, node, parent, printStack);
|
||||
}
|
||||
|
||||
|
||||
54
tools/node_modules/eslint/node_modules/@babel/generator/lib/node/parentheses.js
generated
vendored
54
tools/node_modules/eslint/node_modules/@babel/generator/lib/node/parentheses.js
generated
vendored
@@ -27,9 +27,7 @@ exports.UnaryLike = UnaryLike;
|
||||
exports.IntersectionTypeAnnotation = exports.UnionTypeAnnotation = UnionTypeAnnotation;
|
||||
exports.UpdateExpression = UpdateExpression;
|
||||
exports.AwaitExpression = exports.YieldExpression = YieldExpression;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
isArrayTypeAnnotation,
|
||||
isArrowFunctionExpression,
|
||||
@@ -111,132 +109,112 @@ const PRECEDENCE = {
|
||||
"%": 9,
|
||||
"**": 10
|
||||
};
|
||||
|
||||
const isClassExtendsClause = (node, parent) => isClass(parent, {
|
||||
superClass: node
|
||||
});
|
||||
|
||||
const hasPostfixPart = (node, parent) => (isMemberExpression(parent) || isOptionalMemberExpression(parent)) && parent.object === node || (isCallExpression(parent) || isOptionalCallExpression(parent) || isNewExpression(parent)) && parent.callee === node || isTaggedTemplateExpression(parent) && parent.tag === node || isTSNonNullExpression(parent);
|
||||
|
||||
function NullableTypeAnnotation(node, parent) {
|
||||
return isArrayTypeAnnotation(parent);
|
||||
}
|
||||
|
||||
function FunctionTypeAnnotation(node, parent, printStack) {
|
||||
if (printStack.length < 3) return;
|
||||
return isUnionTypeAnnotation(parent) || isIntersectionTypeAnnotation(parent) || isArrayTypeAnnotation(parent) || isTypeAnnotation(parent) && isArrowFunctionExpression(printStack[printStack.length - 3]);
|
||||
return (
|
||||
isUnionTypeAnnotation(parent) ||
|
||||
isIntersectionTypeAnnotation(parent) ||
|
||||
isArrayTypeAnnotation(parent) ||
|
||||
isTypeAnnotation(parent) &&
|
||||
isArrowFunctionExpression(printStack[printStack.length - 3])
|
||||
);
|
||||
}
|
||||
|
||||
function UpdateExpression(node, parent) {
|
||||
return hasPostfixPart(node, parent) || isClassExtendsClause(node, parent);
|
||||
}
|
||||
|
||||
function ObjectExpression(node, parent, printStack) {
|
||||
return isFirstInContext(printStack, 1 | 2);
|
||||
}
|
||||
|
||||
function DoExpression(node, parent, printStack) {
|
||||
return !node.async && isFirstInContext(printStack, 1);
|
||||
}
|
||||
|
||||
function Binary(node, parent) {
|
||||
if (node.operator === "**" && isBinaryExpression(parent, {
|
||||
operator: "**"
|
||||
})) {
|
||||
return parent.left === node;
|
||||
}
|
||||
|
||||
if (isClassExtendsClause(node, parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hasPostfixPart(node, parent) || isUnaryLike(parent) || isAwaitExpression(parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isBinary(parent)) {
|
||||
const parentOp = parent.operator;
|
||||
const parentPos = PRECEDENCE[parentOp];
|
||||
const nodeOp = node.operator;
|
||||
const nodePos = PRECEDENCE[nodeOp];
|
||||
|
||||
if (parentPos === nodePos && parent.right === node && !isLogicalExpression(parent) || parentPos > nodePos) {
|
||||
if (
|
||||
parentPos === nodePos && parent.right === node && !isLogicalExpression(parent) || parentPos > nodePos) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function UnionTypeAnnotation(node, parent) {
|
||||
return isArrayTypeAnnotation(parent) || isNullableTypeAnnotation(parent) || isIntersectionTypeAnnotation(parent) || isUnionTypeAnnotation(parent);
|
||||
}
|
||||
|
||||
function OptionalIndexedAccessType(node, parent) {
|
||||
return isIndexedAccessType(parent, {
|
||||
objectType: node
|
||||
});
|
||||
}
|
||||
|
||||
function TSAsExpression() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function TSUnionType(node, parent) {
|
||||
return isTSArrayType(parent) || isTSOptionalType(parent) || isTSIntersectionType(parent) || isTSUnionType(parent) || isTSRestType(parent);
|
||||
}
|
||||
|
||||
function TSInferType(node, parent) {
|
||||
return isTSArrayType(parent) || isTSOptionalType(parent);
|
||||
}
|
||||
|
||||
function TSInstantiationExpression(node, parent) {
|
||||
return (isCallExpression(parent) || isOptionalCallExpression(parent) || isNewExpression(parent) || isTSInstantiationExpression(parent)) && !!parent.typeParameters;
|
||||
}
|
||||
|
||||
function BinaryExpression(node, parent) {
|
||||
return node.operator === "in" && (isVariableDeclarator(parent) || isFor(parent));
|
||||
}
|
||||
|
||||
function SequenceExpression(node, parent) {
|
||||
if (isForStatement(parent) || isThrowStatement(parent) || isReturnStatement(parent) || isIfStatement(parent) && parent.test === node || isWhileStatement(parent) && parent.test === node || isForInStatement(parent) && parent.right === node || isSwitchStatement(parent) && parent.discriminant === node || isExpressionStatement(parent) && parent.expression === node) {
|
||||
if (
|
||||
isForStatement(parent) || isThrowStatement(parent) || isReturnStatement(parent) || isIfStatement(parent) && parent.test === node || isWhileStatement(parent) && parent.test === node || isForInStatement(parent) && parent.right === node || isSwitchStatement(parent) && parent.discriminant === node || isExpressionStatement(parent) && parent.expression === node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function YieldExpression(node, parent) {
|
||||
return isBinary(parent) || isUnaryLike(parent) || hasPostfixPart(node, parent) || isAwaitExpression(parent) && isYieldExpression(node) || isConditionalExpression(parent) && node === parent.test || isClassExtendsClause(node, parent);
|
||||
}
|
||||
|
||||
function ClassExpression(node, parent, printStack) {
|
||||
return isFirstInContext(printStack, 1 | 4);
|
||||
}
|
||||
|
||||
function UnaryLike(node, parent) {
|
||||
return hasPostfixPart(node, parent) || isBinaryExpression(parent, {
|
||||
operator: "**",
|
||||
left: node
|
||||
}) || isClassExtendsClause(node, parent);
|
||||
}
|
||||
|
||||
function FunctionExpression(node, parent, printStack) {
|
||||
return isFirstInContext(printStack, 1 | 4);
|
||||
}
|
||||
|
||||
function ArrowFunctionExpression(node, parent) {
|
||||
return isExportDeclaration(parent) || ConditionalExpression(node, parent);
|
||||
}
|
||||
|
||||
function ConditionalExpression(node, parent) {
|
||||
if (isUnaryLike(parent) || isBinary(parent) || isConditionalExpression(parent, {
|
||||
test: node
|
||||
}) || isAwaitExpression(parent) || isTSTypeAssertion(parent) || isTSAsExpression(parent) || isTSSatisfiesExpression(parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return UnaryLike(node, parent);
|
||||
}
|
||||
|
||||
function OptionalMemberExpression(node, parent) {
|
||||
return isCallExpression(parent, {
|
||||
callee: node
|
||||
@@ -244,7 +222,6 @@ function OptionalMemberExpression(node, parent) {
|
||||
object: node
|
||||
});
|
||||
}
|
||||
|
||||
function AssignmentExpression(node, parent) {
|
||||
if (isObjectPattern(node.left)) {
|
||||
return true;
|
||||
@@ -252,32 +229,26 @@ function AssignmentExpression(node, parent) {
|
||||
return ConditionalExpression(node, parent);
|
||||
}
|
||||
}
|
||||
|
||||
function LogicalExpression(node, parent) {
|
||||
switch (node.operator) {
|
||||
case "||":
|
||||
if (!isLogicalExpression(parent)) return false;
|
||||
return parent.operator === "??" || parent.operator === "&&";
|
||||
|
||||
case "&&":
|
||||
return isLogicalExpression(parent, {
|
||||
operator: "??"
|
||||
});
|
||||
|
||||
case "??":
|
||||
return isLogicalExpression(parent) && parent.operator !== "??";
|
||||
}
|
||||
}
|
||||
|
||||
function Identifier(node, parent, printStack) {
|
||||
var _node$extra;
|
||||
|
||||
if ((_node$extra = node.extra) != null && _node$extra.parenthesized && isAssignmentExpression(parent, {
|
||||
left: node
|
||||
}) && (isFunctionExpression(parent.right) || isClassExpression(parent.right)) && parent.right.id == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (node.name === "let") {
|
||||
const isFollowedByBracket = isMemberExpression(parent, {
|
||||
object: node,
|
||||
@@ -305,7 +276,6 @@ function isFirstInContext(printStack, checkParam) {
|
||||
let node = printStack[i];
|
||||
i--;
|
||||
let parent = printStack[i];
|
||||
|
||||
while (i >= 0) {
|
||||
if (expressionStatement && isExpressionStatement(parent, {
|
||||
expression: node
|
||||
@@ -322,7 +292,6 @@ function isFirstInContext(printStack, checkParam) {
|
||||
})) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (i > 0 && (hasPostfixPart(node, parent) && !isNewExpression(parent) || isSequenceExpression(parent) && parent.expressions[0] === node || isUpdateExpression(parent) && !parent.prefix || isConditional(parent, {
|
||||
test: node
|
||||
}) || isBinary(parent, {
|
||||
@@ -337,7 +306,6 @@ function isFirstInContext(printStack, checkParam) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
24
tools/node_modules/eslint/node_modules/@babel/generator/lib/node/whitespace.js
generated
vendored
24
tools/node_modules/eslint/node_modules/@babel/generator/lib/node/whitespace.js
generated
vendored
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.nodes = void 0;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
FLIPPED_ALIAS_KEYS,
|
||||
isArrayExpression,
|
||||
@@ -23,10 +21,8 @@ const {
|
||||
isOptionalMemberExpression,
|
||||
isStringLiteral
|
||||
} = _t;
|
||||
|
||||
function crawlInternal(node, state) {
|
||||
if (!node) return state;
|
||||
|
||||
if (isMemberExpression(node) || isOptionalMemberExpression(node)) {
|
||||
crawlInternal(node.object, state);
|
||||
if (node.computed) crawlInternal(node.property, state);
|
||||
@@ -39,9 +35,9 @@ function crawlInternal(node, state) {
|
||||
} else if (isFunction(node)) {
|
||||
state.hasFunction = true;
|
||||
} else if (isIdentifier(node)) {
|
||||
state.hasHelper = state.hasHelper || node.callee && isHelper(node.callee);
|
||||
state.hasHelper =
|
||||
state.hasHelper || node.callee && isHelper(node.callee);
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -55,7 +51,6 @@ function crawl(node) {
|
||||
|
||||
function isHelper(node) {
|
||||
if (!node) return false;
|
||||
|
||||
if (isMemberExpression(node)) {
|
||||
return isHelper(node.object) || isHelper(node.property);
|
||||
} else if (isIdentifier(node)) {
|
||||
@@ -68,15 +63,14 @@ function isHelper(node) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isType(node) {
|
||||
return isLiteral(node) || isObjectExpression(node) || isArrayExpression(node) || isIdentifier(node) || isMemberExpression(node);
|
||||
}
|
||||
|
||||
const nodes = {
|
||||
|
||||
AssignmentExpression(node) {
|
||||
const state = crawl(node.right);
|
||||
|
||||
if (state.hasCall && state.hasHelper || state.hasFunction) {
|
||||
return state.hasFunction ? 1 | 2 : 2;
|
||||
}
|
||||
@@ -103,7 +97,6 @@ const nodes = {
|
||||
return 1 | 2;
|
||||
}
|
||||
},
|
||||
|
||||
OptionalCallExpression(node) {
|
||||
if (isFunction(node.callee)) {
|
||||
return 1 | 2;
|
||||
@@ -114,12 +107,10 @@ const nodes = {
|
||||
for (let i = 0; i < node.declarations.length; i++) {
|
||||
const declar = node.declarations[i];
|
||||
let enabled = isHelper(declar.id) && !isType(declar.init);
|
||||
|
||||
if (!enabled && declar.init) {
|
||||
const state = crawl(declar.init);
|
||||
enabled = isHelper(declar.init) && state.hasCall || state.hasFunction;
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
return 1 | 2;
|
||||
}
|
||||
@@ -131,8 +122,8 @@ const nodes = {
|
||||
return 1 | 2;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
exports.nodes = nodes;
|
||||
|
||||
nodes.ObjectProperty = nodes.ObjectTypeProperty = nodes.ObjectMethod = function (node, parent) {
|
||||
@@ -140,26 +131,20 @@ nodes.ObjectProperty = nodes.ObjectTypeProperty = nodes.ObjectMethod = function
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
nodes.ObjectTypeCallProperty = function (node, parent) {
|
||||
var _parent$properties;
|
||||
|
||||
if (parent.callProperties[0] === node && !((_parent$properties = parent.properties) != null && _parent$properties.length)) {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
nodes.ObjectTypeIndexer = function (node, parent) {
|
||||
var _parent$properties2, _parent$callPropertie;
|
||||
|
||||
if (parent.indexers[0] === node && !((_parent$properties2 = parent.properties) != null && _parent$properties2.length) && !((_parent$callPropertie = parent.callProperties) != null && _parent$callPropertie.length)) {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
nodes.ObjectTypeInternalSlot = function (node, parent) {
|
||||
var _parent$properties3, _parent$callPropertie2, _parent$indexers;
|
||||
|
||||
if (parent.internalSlots[0] === node && !((_parent$properties3 = parent.properties) != null && _parent$properties3.length) && !((_parent$callPropertie2 = parent.callProperties) != null && _parent$callPropertie2.length) && !((_parent$indexers = parent.indexers) != null && _parent$indexers.length)) {
|
||||
return 1;
|
||||
}
|
||||
@@ -168,7 +153,6 @@ nodes.ObjectTypeInternalSlot = function (node, parent) {
|
||||
[["Function", true], ["Class", true], ["Loop", true], ["LabeledStatement", true], ["SwitchStatement", true], ["TryStatement", true]].forEach(function ([type, amounts]) {
|
||||
[type].concat(FLIPPED_ALIAS_KEYS[type] || []).forEach(function (type) {
|
||||
const ret = amounts ? 1 | 2 : 0;
|
||||
|
||||
nodes[type] = () => ret;
|
||||
});
|
||||
});
|
||||
|
||||
399
tools/node_modules/eslint/node_modules/@babel/generator/lib/printer.js
generated
vendored
399
tools/node_modules/eslint/node_modules/@babel/generator/lib/printer.js
generated
vendored
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _buffer = require("./buffer");
|
||||
|
||||
var n = require("./node");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var generatorFunctions = require("./generators");
|
||||
|
||||
const {
|
||||
isFunction,
|
||||
isStatement,
|
||||
@@ -23,10 +18,10 @@ const SCIENTIFIC_NOTATION = /e/i;
|
||||
const ZERO_DECIMAL_INTEGER = /\.0+$/;
|
||||
const NON_DECIMAL_LITERAL = /^0[box]/;
|
||||
const PURE_ANNOTATION_RE = /^\s*[@#]__PURE__\s*$/;
|
||||
const HAS_NEWLINE = /[\n\r\u2028\u2029]/;
|
||||
const {
|
||||
needsParens
|
||||
} = n;
|
||||
|
||||
class Printer {
|
||||
constructor(format, map) {
|
||||
this.inForStatementInitCounter = 0;
|
||||
@@ -42,17 +37,16 @@ class Printer {
|
||||
this._endsWithInteger = false;
|
||||
this._endsWithWord = false;
|
||||
this._lastCommentLine = 0;
|
||||
this._endsWithInnerRaw = false;
|
||||
this._indentInnerComments = true;
|
||||
this.format = format;
|
||||
this._buf = new _buffer.default(map);
|
||||
this._indentChar = format.indent.style.charCodeAt(0);
|
||||
this._indentRepeat = format.indent.style.length;
|
||||
}
|
||||
|
||||
generate(ast) {
|
||||
this.print(ast);
|
||||
|
||||
this._maybeAddAuxComment();
|
||||
|
||||
return this._buf.get();
|
||||
}
|
||||
|
||||
@@ -68,201 +62,165 @@ class Printer {
|
||||
|
||||
semicolon(force = false) {
|
||||
this._maybeAddAuxComment();
|
||||
|
||||
if (force) {
|
||||
this._appendChar(59);
|
||||
} else {
|
||||
this._queue(59);
|
||||
}
|
||||
this._noLineTerminator = false;
|
||||
}
|
||||
|
||||
rightBrace() {
|
||||
if (this.format.minified) {
|
||||
this._buf.removeLastSemicolon();
|
||||
}
|
||||
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
space(force = false) {
|
||||
if (this.format.compact) return;
|
||||
|
||||
if (force) {
|
||||
this._space();
|
||||
} else if (this._buf.hasContent()) {
|
||||
const lastCp = this.getLastChar();
|
||||
|
||||
if (lastCp !== 32 && lastCp !== 10) {
|
||||
this._space();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
word(str) {
|
||||
word(str, noLineTerminatorAfter = false) {
|
||||
this._maybePrintInnerComments();
|
||||
|
||||
if (this._endsWithWord || str.charCodeAt(0) === 47 && this.endsWith(47)) {
|
||||
this._space();
|
||||
}
|
||||
|
||||
this._maybeAddAuxComment();
|
||||
|
||||
this._append(str, false);
|
||||
|
||||
this._endsWithWord = true;
|
||||
this._noLineTerminator = noLineTerminatorAfter;
|
||||
}
|
||||
|
||||
number(str) {
|
||||
this.word(str);
|
||||
|
||||
this._endsWithInteger = Number.isInteger(+str) && !NON_DECIMAL_LITERAL.test(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && str.charCodeAt(str.length - 1) !== 46;
|
||||
}
|
||||
|
||||
token(str, maybeNewline = false) {
|
||||
this._maybePrintInnerComments();
|
||||
|
||||
const lastChar = this.getLastChar();
|
||||
const strFirst = str.charCodeAt(0);
|
||||
|
||||
if (lastChar === 33 && str === "--" || strFirst === 43 && lastChar === 43 || strFirst === 45 && lastChar === 45 || strFirst === 46 && this._endsWithInteger) {
|
||||
if (lastChar === 33 && str === "--" ||
|
||||
strFirst === 43 && lastChar === 43 || strFirst === 45 && lastChar === 45 ||
|
||||
strFirst === 46 && this._endsWithInteger) {
|
||||
this._space();
|
||||
}
|
||||
|
||||
this._maybeAddAuxComment();
|
||||
|
||||
this._append(str, maybeNewline);
|
||||
this._noLineTerminator = false;
|
||||
}
|
||||
|
||||
tokenChar(char) {
|
||||
const lastChar = this.getLastChar();
|
||||
this._maybePrintInnerComments();
|
||||
|
||||
if (char === 43 && lastChar === 43 || char === 45 && lastChar === 45 || char === 46 && this._endsWithInteger) {
|
||||
const lastChar = this.getLastChar();
|
||||
if (
|
||||
char === 43 && lastChar === 43 || char === 45 && lastChar === 45 ||
|
||||
char === 46 && this._endsWithInteger) {
|
||||
this._space();
|
||||
}
|
||||
|
||||
this._maybeAddAuxComment();
|
||||
|
||||
this._appendChar(char);
|
||||
this._noLineTerminator = false;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
i -= this._buf.getNewlineCount();
|
||||
for (let j = 0; j < i; j++) {
|
||||
this._newline();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
endsWith(char) {
|
||||
return this.getLastChar() === char;
|
||||
}
|
||||
|
||||
getLastChar() {
|
||||
return this._buf.getLastChar();
|
||||
}
|
||||
|
||||
endsWithCharAndNewline() {
|
||||
return this._buf.endsWithCharAndNewline();
|
||||
}
|
||||
|
||||
removeTrailingNewline() {
|
||||
this._buf.removeTrailingNewline();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
_space() {
|
||||
this._queue(32);
|
||||
}
|
||||
|
||||
_newline() {
|
||||
this._queue(10);
|
||||
}
|
||||
|
||||
_append(str, maybeNewline) {
|
||||
this._maybeAddParen(str);
|
||||
|
||||
this._maybeIndent(str.charCodeAt(0));
|
||||
|
||||
this._buf.append(str, maybeNewline);
|
||||
|
||||
this._endsWithWord = false;
|
||||
this._endsWithInteger = false;
|
||||
}
|
||||
|
||||
_appendChar(char) {
|
||||
this._maybeAddParenChar(char);
|
||||
|
||||
this._maybeIndent(char);
|
||||
|
||||
this._buf.appendChar(char);
|
||||
|
||||
this._endsWithWord = false;
|
||||
this._endsWithInteger = false;
|
||||
}
|
||||
|
||||
_queue(char) {
|
||||
this._maybeAddParenChar(char);
|
||||
|
||||
this._maybeIndent(char);
|
||||
|
||||
this._buf.queue(char);
|
||||
|
||||
this._endsWithWord = false;
|
||||
this._endsWithInteger = false;
|
||||
}
|
||||
|
||||
_maybeIndent(firstChar) {
|
||||
if (this._indent && firstChar !== 10 && this.endsWith(10)) {
|
||||
this._buf.queueIndentation(this._indentChar, this._getIndent());
|
||||
}
|
||||
}
|
||||
|
||||
_shouldIndent(firstChar) {
|
||||
if (this._indent && firstChar !== 10 && this.endsWith(10)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
_maybeAddParenChar(char) {
|
||||
const parenPushNewlineState = this._parenPushNewlineState;
|
||||
if (!parenPushNewlineState) return;
|
||||
@@ -275,66 +233,59 @@ class Printer {
|
||||
this._parenPushNewlineState = null;
|
||||
return;
|
||||
}
|
||||
|
||||
this.tokenChar(40);
|
||||
this.indent();
|
||||
parenPushNewlineState.printed = true;
|
||||
}
|
||||
|
||||
_maybeAddParen(str) {
|
||||
const parenPushNewlineState = this._parenPushNewlineState;
|
||||
if (!parenPushNewlineState) return;
|
||||
|
||||
const len = str.length;
|
||||
let i;
|
||||
|
||||
for (i = 0; i < len && str.charCodeAt(i) === 32; i++) continue;
|
||||
|
||||
if (i === len) {
|
||||
return;
|
||||
}
|
||||
|
||||
const cha = str.charCodeAt(i);
|
||||
|
||||
if (cha !== 10) {
|
||||
if (cha !== 47 || i + 1 === len) {
|
||||
if (
|
||||
cha !== 47 ||
|
||||
i + 1 === len) {
|
||||
this._parenPushNewlineState = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const chaPost = str.charCodeAt(i + 1);
|
||||
|
||||
if (chaPost === 42) {
|
||||
|
||||
if (PURE_ANNOTATION_RE.test(str.slice(i + 2, len - 2))) {
|
||||
return;
|
||||
}
|
||||
|
||||
} else if (chaPost !== 47) {
|
||||
this._parenPushNewlineState = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.tokenChar(40);
|
||||
this.indent();
|
||||
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;
|
||||
|
||||
const pos = loc ? loc[prop] : null;
|
||||
if ((pos == null ? void 0 : pos.line) != null) {
|
||||
const count = pos.line - this._buf.getCurrentLine();
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
this._newline();
|
||||
}
|
||||
@@ -344,28 +295,16 @@ class Printer {
|
||||
_getIndent() {
|
||||
return this._indentRepeat * this._indent;
|
||||
}
|
||||
|
||||
ensureNoLineTerminator(fn) {
|
||||
const {
|
||||
_noLineTerminator
|
||||
} = this;
|
||||
this._noLineTerminator = true;
|
||||
fn();
|
||||
this._noLineTerminator = _noLineTerminator;
|
||||
}
|
||||
|
||||
printTerminatorless(node, parent, isLabel) {
|
||||
if (isLabel) {
|
||||
this.ensureNoLineTerminator(() => {
|
||||
this.print(node, parent);
|
||||
});
|
||||
this._noLineTerminator = true;
|
||||
this.print(node, parent);
|
||||
} else {
|
||||
const terminatorState = {
|
||||
printed: false
|
||||
};
|
||||
this._parenPushNewlineState = terminatorState;
|
||||
this.print(node, parent);
|
||||
|
||||
if (terminatorState.printed) {
|
||||
this.dedent();
|
||||
this.newline();
|
||||
@@ -373,32 +312,26 @@ class Printer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print(node, parent, noLineTerminator, trailingCommentsLineOffset, forceParens) {
|
||||
print(node, parent, noLineTerminatorAfter,
|
||||
trailingCommentsLineOffset, forceParens) {
|
||||
if (!node) return;
|
||||
this._endsWithInnerRaw = false;
|
||||
const nodeType = node.type;
|
||||
const format = this.format;
|
||||
const oldConcise = format.concise;
|
||||
|
||||
if (node._compact) {
|
||||
if (
|
||||
node._compact) {
|
||||
format.concise = true;
|
||||
}
|
||||
|
||||
const printMethod = this[nodeType];
|
||||
|
||||
if (printMethod === undefined) {
|
||||
throw new ReferenceError(`unknown node of type ${JSON.stringify(nodeType)} with constructor ${JSON.stringify(node.constructor.name)}`);
|
||||
}
|
||||
|
||||
this._printStack.push(node);
|
||||
|
||||
const oldInAux = this._insideAux;
|
||||
this._insideAux = node.loc == undefined;
|
||||
|
||||
this._maybeAddAuxComment(this._insideAux && !oldInAux);
|
||||
|
||||
let shouldPrintParens = false;
|
||||
|
||||
if (forceParens) {
|
||||
shouldPrintParens = true;
|
||||
} else if (format.retainFunctionParens && nodeType === "FunctionExpression" && node.extra && node.extra.parenthesized) {
|
||||
@@ -406,43 +339,35 @@ class Printer {
|
||||
} else {
|
||||
shouldPrintParens = needsParens(node, parent, this._printStack);
|
||||
}
|
||||
|
||||
if (shouldPrintParens) this.tokenChar(40);
|
||||
this._lastCommentLine = 0;
|
||||
|
||||
this._printLeadingComments(node, parent);
|
||||
|
||||
const loc = nodeType === "Program" || nodeType === "File" ? null : node.loc;
|
||||
this.exactSource(loc, printMethod.bind(this, node, parent));
|
||||
|
||||
if (noLineTerminator && !this._noLineTerminator) {
|
||||
this._noLineTerminator = true;
|
||||
|
||||
if (shouldPrintParens) {
|
||||
this._printTrailingComments(node, parent);
|
||||
this.tokenChar(41);
|
||||
this._noLineTerminator = noLineTerminatorAfter;
|
||||
} else if (noLineTerminatorAfter && !this._noLineTerminator) {
|
||||
this._noLineTerminator = true;
|
||||
this._printTrailingComments(node, parent);
|
||||
|
||||
this._noLineTerminator = false;
|
||||
} else {
|
||||
this._printTrailingComments(node, parent, trailingCommentsLineOffset);
|
||||
}
|
||||
|
||||
if (shouldPrintParens) this.tokenChar(41);
|
||||
|
||||
this._printStack.pop();
|
||||
|
||||
format.concise = oldConcise;
|
||||
this._insideAux = oldInAux;
|
||||
this._endsWithInnerRaw = false;
|
||||
}
|
||||
|
||||
_maybeAddAuxComment(enteredPositionlessNode) {
|
||||
if (enteredPositionlessNode) this._printAuxBeforeComment();
|
||||
if (!this._insideAux) this._printAuxAfterComment();
|
||||
}
|
||||
|
||||
_printAuxBeforeComment() {
|
||||
if (this._printAuxAfterOnNextUserNode) return;
|
||||
this._printAuxAfterOnNextUserNode = true;
|
||||
const comment = this.format.auxiliaryCommentBefore;
|
||||
|
||||
if (comment) {
|
||||
this._printComment({
|
||||
type: "CommentBlock",
|
||||
@@ -450,12 +375,10 @@ class Printer {
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
_printAuxAfterComment() {
|
||||
if (!this._printAuxAfterOnNextUserNode) return;
|
||||
this._printAuxAfterOnNextUserNode = false;
|
||||
const comment = this.format.auxiliaryCommentAfter;
|
||||
|
||||
if (comment) {
|
||||
this._printComment({
|
||||
type: "CommentBlock",
|
||||
@@ -463,15 +386,12 @@ class Printer {
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
getPossibleRaw(node) {
|
||||
const extra = node.extra;
|
||||
|
||||
if (extra && extra.raw != null && extra.rawValue != null && node.value === extra.rawValue) {
|
||||
return extra.raw;
|
||||
}
|
||||
}
|
||||
|
||||
printJoin(nodes, parent, opts = {}) {
|
||||
if (!(nodes != null && nodes.length)) return;
|
||||
if (opts.indent) this.indent();
|
||||
@@ -481,7 +401,6 @@ class Printer {
|
||||
};
|
||||
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;
|
||||
@@ -489,81 +408,74 @@ class Printer {
|
||||
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.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.indent) this.dedent();
|
||||
}
|
||||
|
||||
printAndIndentOnComments(node, parent) {
|
||||
const indent = node.leadingComments && node.leadingComments.length > 0;
|
||||
if (indent) this.indent();
|
||||
this.print(node, parent);
|
||||
if (indent) this.dedent();
|
||||
}
|
||||
|
||||
printBlock(parent) {
|
||||
const node = parent.body;
|
||||
|
||||
if (node.type !== "EmptyStatement") {
|
||||
this.space();
|
||||
}
|
||||
|
||||
this.print(node, parent);
|
||||
}
|
||||
|
||||
_printTrailingComments(node, parent, lineOffset) {
|
||||
const comments = this._getComments(false, node);
|
||||
|
||||
const comments = node.trailingComments;
|
||||
if (!(comments != null && comments.length)) return;
|
||||
|
||||
this._printComments(2, comments, node, parent, lineOffset);
|
||||
}
|
||||
|
||||
_printLeadingComments(node, parent) {
|
||||
const comments = this._getComments(true, node);
|
||||
|
||||
const comments = node.leadingComments;
|
||||
if (!(comments != null && comments.length)) return;
|
||||
|
||||
this._printComments(0, comments, node, parent);
|
||||
}
|
||||
|
||||
printInnerComments(node, indent = true) {
|
||||
var _node$innerComments;
|
||||
|
||||
if (!((_node$innerComments = node.innerComments) != null && _node$innerComments.length)) return;
|
||||
_maybePrintInnerComments() {
|
||||
if (this._endsWithInnerRaw) this.printInnerComments();
|
||||
this._endsWithInnerRaw = true;
|
||||
this._indentInnerComments = true;
|
||||
}
|
||||
printInnerComments() {
|
||||
const node = this._printStack[this._printStack.length - 1];
|
||||
const comments = node.innerComments;
|
||||
if (!(comments != null && comments.length)) return;
|
||||
const hasSpace = this.endsWith(32);
|
||||
const indent = this._indentInnerComments;
|
||||
const printedCommentsCount = this._printedComments.size;
|
||||
if (indent) this.indent();
|
||||
|
||||
this._printComments(1, node.innerComments, node);
|
||||
|
||||
this._printComments(1, comments, node);
|
||||
if (hasSpace && printedCommentsCount !== this._printedComments.size) {
|
||||
this.space();
|
||||
}
|
||||
if (indent) this.dedent();
|
||||
}
|
||||
|
||||
noIndentInnerCommentsHere() {
|
||||
this._indentInnerComments = false;
|
||||
}
|
||||
printSequence(nodes, parent, opts = {}) {
|
||||
opts.statement = true;
|
||||
return this.printJoin(nodes, parent, opts);
|
||||
}
|
||||
|
||||
printList(items, parent, opts = {}) {
|
||||
if (opts.separator == null) {
|
||||
opts.separator = commaSeparator;
|
||||
}
|
||||
|
||||
return this.printJoin(items, parent, opts);
|
||||
}
|
||||
|
||||
_printNewline(newLine, opts) {
|
||||
if (this.format.retainLines || this.format.compact) return;
|
||||
|
||||
@@ -571,17 +483,13 @@ class Printer {
|
||||
this.space();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!newLine) {
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -589,55 +497,43 @@ class Printer {
|
||||
}
|
||||
|
||||
if (this._buf.hasContent()) {
|
||||
|
||||
this.newline(1);
|
||||
}
|
||||
}
|
||||
|
||||
_getComments(leading, node) {
|
||||
return node && (leading ? node.leadingComments : node.trailingComments) || null;
|
||||
}
|
||||
|
||||
_printComment(comment, skipNewLines) {
|
||||
if (comment.ignore) return;
|
||||
if (this._printedComments.has(comment)) return;
|
||||
if (!this.format.shouldPrintComment(comment.value)) return;
|
||||
|
||||
if (comment.ignore) return false;
|
||||
if (this._printedComments.has(comment)) return false;
|
||||
if (this._noLineTerminator && HAS_NEWLINE.test(comment.value)) {
|
||||
return true;
|
||||
}
|
||||
if (!this.format.shouldPrintComment(comment.value)) return false;
|
||||
this._printedComments.add(comment);
|
||||
|
||||
const isBlockComment = comment.type === "CommentBlock";
|
||||
const printNewLines = isBlockComment && skipNewLines !== 1 && !this._noLineTerminator;
|
||||
|
||||
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) {
|
||||
this.space();
|
||||
}
|
||||
|
||||
let val;
|
||||
|
||||
if (isBlockComment) {
|
||||
val = `/*${comment.value}*/`;
|
||||
|
||||
if (this.format.indent.adjustMultilineComment) {
|
||||
var _comment$loc;
|
||||
|
||||
const offset = (_comment$loc = comment.loc) == null ? void 0 : _comment$loc.start.column;
|
||||
|
||||
if (offset) {
|
||||
const newlineRegex = new RegExp("\\n\\s{1," + offset + "}", "g");
|
||||
val = val.replace(newlineRegex, "\n");
|
||||
}
|
||||
|
||||
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)}`);
|
||||
}
|
||||
} else if (!this._noLineTerminator) {
|
||||
@@ -648,113 +544,91 @@ class Printer {
|
||||
|
||||
if (this.endsWith(47)) this._space();
|
||||
this.source("start", comment.loc);
|
||||
|
||||
this._append(val, isBlockComment);
|
||||
|
||||
if (!isBlockComment && !this._noLineTerminator) {
|
||||
this.newline(1, true);
|
||||
}
|
||||
|
||||
if (printNewLines && skipNewLines !== 3) {
|
||||
this.newline(1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
_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;
|
||||
|
||||
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;
|
||||
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;
|
||||
const {
|
||||
_noLineTerminator
|
||||
} = this;
|
||||
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 {
|
||||
const offset = commentStartLine - (i === 0 ? nodeEndLine - lineOffset : lastLine);
|
||||
lastLine = commentEndLine;
|
||||
this.newline(offset);
|
||||
|
||||
this._printComment(comment, 1);
|
||||
offset = commentStartLine - lastLine;
|
||||
}
|
||||
lastLine = commentEndLine;
|
||||
if (!_noLineTerminator) this.newline(offset);
|
||||
this._printComment(comment, 1);
|
||||
if (!_noLineTerminator && 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;
|
||||
if (!_noLineTerminator) this.newline(offset);
|
||||
if (this._printComment(comment, 1)) break;
|
||||
if (!_noLineTerminator && i + 1 === len) {
|
||||
this.newline(Math.min(1, nodeEndLine - lastLine));
|
||||
lastLine = nodeEndLine;
|
||||
}
|
||||
} 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);
|
||||
const offset = commentStartLine - (i === 0 ? nodeEndLine - lineOffset : lastLine);
|
||||
lastLine = commentEndLine;
|
||||
if (!_noLineTerminator) 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) {
|
||||
if (this._printComment(comment, 1)) {
|
||||
break;
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
} else if (type === 1 && !(node.type === "ObjectExpression" && node.properties.length > 1) && node.type !== "ClassBody" && node.type !== "TSInterfaceBody") {
|
||||
|
||||
const skippedDueToNewlie = this._printComment(comment, i === 0 ? 2 : i === len - 1 ? 3 : 0);
|
||||
if (skippedDueToNewlie) break;
|
||||
} else {
|
||||
this._printComment(comment, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (type === 2 && hasLoc && lastLine) {
|
||||
this._lastCommentLine = lastLine;
|
||||
}
|
||||
}
|
||||
if (type === 2 && hasLoc && lastLine) {
|
||||
this._lastCommentLine = lastLine;
|
||||
}
|
||||
}
|
||||
|
||||
printAssertions(node) {
|
||||
this.space();
|
||||
this.printInnerComments(node);
|
||||
this.tokenChar(123);
|
||||
this.space();
|
||||
this.printList(node.assertions, node);
|
||||
this.space();
|
||||
this.tokenChar(125);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Object.assign(Printer.prototype, generatorFunctions);
|
||||
@@ -763,7 +637,6 @@ Object.assign(Printer.prototype, generatorFunctions);
|
||||
}
|
||||
var _default = Printer;
|
||||
exports.default = _default;
|
||||
|
||||
function commaSeparator() {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
|
||||
8
tools/node_modules/eslint/node_modules/@babel/generator/lib/source-map.js
generated
vendored
8
tools/node_modules/eslint/node_modules/@babel/generator/lib/source-map.js
generated
vendored
@@ -4,13 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _genMapping = require("@jridgewell/gen-mapping");
|
||||
|
||||
class SourceMap {
|
||||
|
||||
constructor(opts, code) {
|
||||
var _opts$sourceFileName;
|
||||
|
||||
this._map = void 0;
|
||||
this._rawMappings = void 0;
|
||||
this._sourceFileName = void 0;
|
||||
@@ -22,7 +21,6 @@ class SourceMap {
|
||||
});
|
||||
this._sourceFileName = (_opts$sourceFileName = opts.sourceFileName) == null ? void 0 : _opts$sourceFileName.replace(/\\/g, "/");
|
||||
this._rawMappings = undefined;
|
||||
|
||||
if (typeof code === "string") {
|
||||
(0, _genMapping.setSourceContent)(map, this._sourceFileName, code);
|
||||
} else if (typeof code === "object") {
|
||||
@@ -35,11 +33,9 @@ class SourceMap {
|
||||
get() {
|
||||
return (0, _genMapping.toEncodedMap)(this._map);
|
||||
}
|
||||
|
||||
getDecoded() {
|
||||
return (0, _genMapping.toDecodedMap)(this._map);
|
||||
}
|
||||
|
||||
getRawMappings() {
|
||||
return this._rawMappings || (this._rawMappings = (0, _genMapping.allMappings)(this._map));
|
||||
}
|
||||
@@ -56,9 +52,7 @@ class SourceMap {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = SourceMap;
|
||||
|
||||
//# sourceMappingURL=source-map.js.map
|
||||
|
||||
6
tools/node_modules/eslint/node_modules/@babel/generator/package.json
generated
vendored
6
tools/node_modules/eslint/node_modules/@babel/generator/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/generator",
|
||||
"version": "7.20.0",
|
||||
"version": "7.20.2",
|
||||
"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.20.0",
|
||||
"@babel/types": "^7.20.2",
|
||||
"@jridgewell/gen-mapping": "^0.3.2",
|
||||
"jsesc": "^2.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-fixtures": "^7.19.4",
|
||||
"@babel/parser": "^7.20.0",
|
||||
"@babel/parser": "^7.20.2",
|
||||
"@jridgewell/trace-mapping": "^0.3.8",
|
||||
"@types/jsesc": "^2.5.0",
|
||||
"charcodes": "^0.2.0"
|
||||
|
||||
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getDynamicImportSource = getDynamicImportSource;
|
||||
|
||||
var t = require("@babel/types");
|
||||
|
||||
var _template = require("@babel/template");
|
||||
|
||||
function getDynamicImportSource(node) {
|
||||
|
||||
@@ -9,7 +9,6 @@ exports.default = getModuleName;
|
||||
|
||||
exports.default = getModuleName = function getModuleName(rootOpts, pluginOpts) {
|
||||
var _pluginOpts$moduleId, _pluginOpts$moduleIds, _pluginOpts$getModule, _pluginOpts$moduleRoo;
|
||||
|
||||
return originalGetModuleName(rootOpts, {
|
||||
moduleId: (_pluginOpts$moduleId = pluginOpts.moduleId) != null ? _pluginOpts$moduleId : rootOpts.moduleId,
|
||||
moduleIds: (_pluginOpts$moduleIds = pluginOpts.moduleIds) != null ? _pluginOpts$moduleIds : rootOpts.moduleIds,
|
||||
@@ -18,7 +17,6 @@ exports.default = getModuleName;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function getModuleName(rootOpts, pluginOpts) {
|
||||
const {
|
||||
filename,
|
||||
@@ -36,16 +34,15 @@ function getModuleName(rootOpts, pluginOpts) {
|
||||
if (moduleId != null && !getModuleId) {
|
||||
return moduleId;
|
||||
}
|
||||
|
||||
let moduleName = moduleRoot != null ? moduleRoot + "/" : "";
|
||||
|
||||
if (filenameRelative) {
|
||||
const sourceRootReplacer = sourceRoot != null ? new RegExp("^" + sourceRoot + "/?") : "";
|
||||
moduleName += filenameRelative.replace(sourceRootReplacer, "").replace(/\.(\w*?)$/, "");
|
||||
moduleName += filenameRelative
|
||||
.replace(sourceRootReplacer, "")
|
||||
.replace(/\.(\w*?)$/, "");
|
||||
}
|
||||
|
||||
moduleName = moduleName.replace(/\\/g, "/");
|
||||
|
||||
if (getModuleId) {
|
||||
return getModuleId(moduleName) || moduleName;
|
||||
} else {
|
||||
|
||||
72
tools/node_modules/eslint/node_modules/@babel/helper-module-transforms/lib/index.js
generated
vendored
72
tools/node_modules/eslint/node_modules/@babel/helper-module-transforms/lib/index.js
generated
vendored
@@ -43,25 +43,15 @@ Object.defineProperty(exports, "rewriteThis", {
|
||||
}
|
||||
});
|
||||
exports.wrapInterop = wrapInterop;
|
||||
|
||||
var _assert = require("assert");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var _template = require("@babel/template");
|
||||
|
||||
var _helperModuleImports = require("@babel/helper-module-imports");
|
||||
|
||||
var _rewriteThis = require("./rewrite-this");
|
||||
|
||||
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 {
|
||||
booleanLiteral,
|
||||
callExpression,
|
||||
@@ -77,7 +67,6 @@ const {
|
||||
variableDeclaration,
|
||||
variableDeclarator
|
||||
} = _t;
|
||||
|
||||
function rewriteModuleStatementsAndPrepareHeader(path, {
|
||||
loose,
|
||||
exportName,
|
||||
@@ -94,9 +83,7 @@ function rewriteModuleStatementsAndPrepareHeader(path, {
|
||||
noIncompleteNsImportDetection
|
||||
}) {
|
||||
(0, _normalizeAndLoadMetadata.validateImportInteropOption)(importInterop);
|
||||
|
||||
_assert((0, _helperModuleImports.isModule)(path), "Cannot process module statements in a script");
|
||||
|
||||
path.node.sourceType = "script";
|
||||
const meta = (0, _normalizeAndLoadMetadata.default)(path, exportName, {
|
||||
importInterop,
|
||||
@@ -105,31 +92,23 @@ function rewriteModuleStatementsAndPrepareHeader(path, {
|
||||
esNamespaceOnly,
|
||||
filename
|
||||
});
|
||||
|
||||
if (!allowTopLevelThis) {
|
||||
(0, _rewriteThis.default)(path);
|
||||
}
|
||||
|
||||
(0, _rewriteLiveReferences.default)(path, meta);
|
||||
|
||||
if (strictMode !== false) {
|
||||
const hasStrict = path.node.directives.some(directive => {
|
||||
return directive.value.value === "use strict";
|
||||
});
|
||||
|
||||
if (!hasStrict) {
|
||||
path.unshiftContainer("directives", directive(directiveLiteral("use strict")));
|
||||
}
|
||||
}
|
||||
|
||||
const headers = [];
|
||||
|
||||
if ((0, _normalizeAndLoadMetadata.hasExports)(meta) && !strict) {
|
||||
headers.push(buildESModuleHeader(meta, enumerableModuleMeta));
|
||||
}
|
||||
|
||||
const nameList = buildExportNameListDeclaration(path, meta);
|
||||
|
||||
if (nameList) {
|
||||
meta.exportNameListName = nameList.name;
|
||||
headers.push(nameList.statement);
|
||||
@@ -152,15 +131,12 @@ function wrapInterop(programPath, expr, type) {
|
||||
if (type === "none") {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (type === "node-namespace") {
|
||||
return callExpression(programPath.hub.addHelper("interopRequireWildcard"), [expr, booleanLiteral(true)]);
|
||||
} else if (type === "node-default") {
|
||||
return null;
|
||||
}
|
||||
|
||||
let helper;
|
||||
|
||||
if (type === "default") {
|
||||
helper = "interopRequireDefault";
|
||||
} else if (type === "namespace") {
|
||||
@@ -168,7 +144,6 @@ function wrapInterop(programPath, expr, type) {
|
||||
} else {
|
||||
throw new Error(`Unknown interop: ${type}`);
|
||||
}
|
||||
|
||||
return callExpression(programPath.hub.addHelper(helper), [expr]);
|
||||
}
|
||||
|
||||
@@ -176,19 +151,17 @@ function buildNamespaceInitStatements(metadata, sourceMetadata, constantReexport
|
||||
const statements = [];
|
||||
let srcNamespace = identifier(sourceMetadata.name);
|
||||
if (sourceMetadata.lazy) srcNamespace = callExpression(srcNamespace, []);
|
||||
|
||||
for (const localName of sourceMetadata.importsNamespace) {
|
||||
if (localName === sourceMetadata.name) continue;
|
||||
|
||||
statements.push(_template.default.statement`var NAME = SOURCE;`({
|
||||
NAME: localName,
|
||||
SOURCE: cloneNode(srcNamespace)
|
||||
}));
|
||||
}
|
||||
|
||||
if (constantReexports) {
|
||||
statements.push(...buildReexportsFromMeta(metadata, sourceMetadata, true));
|
||||
}
|
||||
|
||||
for (const exportName of sourceMetadata.reexportNamespace) {
|
||||
statements.push((sourceMetadata.lazy ? _template.default.statement`
|
||||
Object.defineProperty(EXPORTS, "NAME", {
|
||||
@@ -203,16 +176,14 @@ function buildNamespaceInitStatements(metadata, sourceMetadata, constantReexport
|
||||
NAMESPACE: cloneNode(srcNamespace)
|
||||
}));
|
||||
}
|
||||
|
||||
if (sourceMetadata.reexportAll) {
|
||||
const statement = buildNamespaceReexport(metadata, cloneNode(srcNamespace), constantReexports);
|
||||
statement.loc = sourceMetadata.reexportAll.loc;
|
||||
|
||||
statements.push(statement);
|
||||
}
|
||||
|
||||
return statements;
|
||||
}
|
||||
|
||||
const ReexportTemplate = {
|
||||
constant: _template.default.statement`EXPORTS.EXPORT_NAME = NAMESPACE_IMPORT;`,
|
||||
constantComputed: _template.default.statement`EXPORTS["EXPORT_NAME"] = NAMESPACE_IMPORT;`,
|
||||
@@ -225,27 +196,24 @@ const ReexportTemplate = {
|
||||
});
|
||||
`
|
||||
};
|
||||
|
||||
const buildReexportsFromMeta = (meta, metadata, constantReexports) => {
|
||||
function buildReexportsFromMeta(meta, metadata, constantReexports) {
|
||||
const namespace = metadata.lazy ? callExpression(identifier(metadata.name), []) : identifier(metadata.name);
|
||||
const {
|
||||
stringSpecifiers
|
||||
} = meta;
|
||||
return Array.from(metadata.reexports, ([exportName, importName]) => {
|
||||
let NAMESPACE_IMPORT = cloneNode(namespace);
|
||||
|
||||
if (importName === "default" && metadata.interop === "node-default") {} else if (stringSpecifiers.has(importName)) {
|
||||
if (importName === "default" && metadata.interop === "node-default") {
|
||||
} else if (stringSpecifiers.has(importName)) {
|
||||
NAMESPACE_IMPORT = memberExpression(NAMESPACE_IMPORT, stringLiteral(importName), true);
|
||||
} else {
|
||||
NAMESPACE_IMPORT = memberExpression(NAMESPACE_IMPORT, identifier(importName));
|
||||
}
|
||||
|
||||
const astNodes = {
|
||||
EXPORTS: meta.exportName,
|
||||
EXPORT_NAME: exportName,
|
||||
NAMESPACE_IMPORT
|
||||
};
|
||||
|
||||
if (constantReexports || isIdentifier(NAMESPACE_IMPORT)) {
|
||||
if (stringSpecifiers.has(exportName)) {
|
||||
return ReexportTemplate.constantComputed(astNodes);
|
||||
@@ -256,7 +224,7 @@ const buildReexportsFromMeta = (meta, metadata, constantReexports) => {
|
||||
return ReexportTemplate.spec(astNodes);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function buildESModuleHeader(metadata, enumerableModuleMeta = false) {
|
||||
return (enumerableModuleMeta ? _template.default.statement`
|
||||
@@ -279,7 +247,8 @@ function buildNamespaceReexport(metadata, namespace, constantReexports) {
|
||||
|
||||
EXPORTS[key] = NAMESPACE[key];
|
||||
});
|
||||
` : _template.default.statement`
|
||||
` :
|
||||
_template.default.statement`
|
||||
Object.keys(NAMESPACE).forEach(function(key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
VERIFY_NAME_LIST;
|
||||
@@ -305,27 +274,21 @@ function buildNamespaceReexport(metadata, namespace, constantReexports) {
|
||||
|
||||
function buildExportNameListDeclaration(programPath, metadata) {
|
||||
const exportedVars = Object.create(null);
|
||||
|
||||
for (const data of metadata.local.values()) {
|
||||
for (const name of data.names) {
|
||||
exportedVars[name] = true;
|
||||
}
|
||||
}
|
||||
|
||||
let hasReexport = false;
|
||||
|
||||
for (const data of metadata.source.values()) {
|
||||
for (const exportName of data.reexports.keys()) {
|
||||
exportedVars[exportName] = true;
|
||||
}
|
||||
|
||||
for (const exportName of data.reexportNamespace) {
|
||||
exportedVars[exportName] = true;
|
||||
}
|
||||
|
||||
hasReexport = hasReexport || !!data.reexportAll;
|
||||
}
|
||||
|
||||
if (!hasReexport || Object.keys(exportedVars).length === 0) return null;
|
||||
const name = programPath.scope.generateUidIdentifier("exportNames");
|
||||
delete exportedVars.default;
|
||||
@@ -337,27 +300,25 @@ function buildExportNameListDeclaration(programPath, metadata) {
|
||||
|
||||
function buildExportInitializationStatements(programPath, metadata, constantReexports = false, noIncompleteNsImportDetection = false) {
|
||||
const initStatements = [];
|
||||
|
||||
for (const [localName, data] of metadata.local) {
|
||||
if (data.kind === "import") {} else if (data.kind === "hoisted") {
|
||||
initStatements.push([data.names[0], buildInitStatement(metadata, data.names, identifier(localName))]);
|
||||
if (data.kind === "import") {
|
||||
} else if (data.kind === "hoisted") {
|
||||
initStatements.push([
|
||||
data.names[0], buildInitStatement(metadata, data.names, identifier(localName))]);
|
||||
} else if (!noIncompleteNsImportDetection) {
|
||||
for (const exportName of data.names) {
|
||||
initStatements.push([exportName, null]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const data of metadata.source.values()) {
|
||||
if (!constantReexports) {
|
||||
const reexportsStatements = buildReexportsFromMeta(metadata, data, false);
|
||||
const reexports = [...data.reexports.keys()];
|
||||
|
||||
for (let i = 0; i < reexportsStatements.length; i++) {
|
||||
initStatements.push([reexports[i], reexportsStatements[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!noIncompleteNsImportDetection) {
|
||||
for (const exportName of data.reexportNamespace) {
|
||||
initStatements.push([exportName, null]);
|
||||
@@ -371,38 +332,31 @@ function buildExportInitializationStatements(programPath, metadata, constantReex
|
||||
return 0;
|
||||
});
|
||||
const results = [];
|
||||
|
||||
if (noIncompleteNsImportDetection) {
|
||||
for (const [, initStatement] of initStatements) {
|
||||
results.push(initStatement);
|
||||
}
|
||||
} else {
|
||||
const chunkSize = 100;
|
||||
|
||||
for (let i = 0; i < initStatements.length; i += chunkSize) {
|
||||
let uninitializedExportNames = [];
|
||||
|
||||
for (let j = 0; j < chunkSize && i + j < initStatements.length; j++) {
|
||||
const [exportName, initStatement] = initStatements[i + j];
|
||||
|
||||
if (initStatement !== null) {
|
||||
if (uninitializedExportNames.length > 0) {
|
||||
results.push(buildInitStatement(metadata, uninitializedExportNames, programPath.scope.buildUndefinedNode()));
|
||||
uninitializedExportNames = [];
|
||||
}
|
||||
|
||||
results.push(initStatement);
|
||||
} else {
|
||||
uninitializedExportNames.push(exportName);
|
||||
}
|
||||
}
|
||||
|
||||
if (uninitializedExportNames.length > 0) {
|
||||
results.push(buildInitStatement(metadata, uninitializedExportNames, programPath.scope.buildUndefinedNode()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -410,7 +364,6 @@ const InitTemplate = {
|
||||
computed: _template.default.expression`EXPORTS["NAME"] = VALUE`,
|
||||
default: _template.default.expression`EXPORTS.NAME = VALUE`
|
||||
};
|
||||
|
||||
function buildInitStatement(metadata, exportNames, initExpr) {
|
||||
const {
|
||||
stringSpecifiers,
|
||||
@@ -422,7 +375,6 @@ function buildInitStatement(metadata, exportNames, initExpr) {
|
||||
NAME: exportName,
|
||||
VALUE: acc
|
||||
};
|
||||
|
||||
if (stringSpecifiers.has(exportName)) {
|
||||
return InitTemplate.computed(params);
|
||||
} else {
|
||||
|
||||
@@ -7,13 +7,9 @@ exports.default = normalizeModuleAndLoadMetadata;
|
||||
exports.hasExports = hasExports;
|
||||
exports.isSideEffectImport = isSideEffectImport;
|
||||
exports.validateImportInteropOption = validateImportInteropOption;
|
||||
|
||||
var _path = require("path");
|
||||
|
||||
var _helperValidatorIdentifier = require("@babel/helper-validator-identifier");
|
||||
|
||||
var _helperSplitExportDeclaration = require("@babel/helper-split-export-declaration");
|
||||
|
||||
function hasExports(metadata) {
|
||||
return metadata.hasExports;
|
||||
}
|
||||
@@ -21,20 +17,16 @@ function hasExports(metadata) {
|
||||
function isSideEffectImport(source) {
|
||||
return source.imports.size === 0 && source.importsNamespace.size === 0 && source.reexports.size === 0 && source.reexportNamespace.size === 0 && !source.reexportAll;
|
||||
}
|
||||
|
||||
function validateImportInteropOption(importInterop) {
|
||||
if (typeof importInterop !== "function" && importInterop !== "none" && importInterop !== "babel" && importInterop !== "node") {
|
||||
throw new Error(`.importInterop must be one of "none", "babel", "node", or a function returning one of those values (received ${importInterop}).`);
|
||||
}
|
||||
|
||||
return importInterop;
|
||||
}
|
||||
|
||||
function resolveImportInterop(importInterop, source, filename) {
|
||||
if (typeof importInterop === "function") {
|
||||
return validateImportInteropOption(importInterop(source, filename));
|
||||
}
|
||||
|
||||
return importInterop;
|
||||
}
|
||||
|
||||
@@ -48,7 +40,6 @@ function normalizeModuleAndLoadMetadata(programPath, exportName, {
|
||||
if (!exportName) {
|
||||
exportName = programPath.scope.generateUidIdentifier("exports").name;
|
||||
}
|
||||
|
||||
const stringSpecifiers = new Set();
|
||||
nameAnonymousExports(programPath);
|
||||
const {
|
||||
@@ -65,9 +56,7 @@ function normalizeModuleAndLoadMetadata(programPath, exportName, {
|
||||
if (metadata.importsNamespace.size > 0) {
|
||||
metadata.name = metadata.importsNamespace.values().next().value;
|
||||
}
|
||||
|
||||
const resolvedInterop = resolveImportInterop(importInterop, metadata.source, filename);
|
||||
|
||||
if (resolvedInterop === "none") {
|
||||
metadata.interop = "none";
|
||||
} else if (resolvedInterop === "node" && metadata.interop === "namespace") {
|
||||
@@ -78,7 +67,6 @@ function normalizeModuleAndLoadMetadata(programPath, exportName, {
|
||||
metadata.interop = "default";
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
exportName,
|
||||
exportNameListName: null,
|
||||
@@ -88,23 +76,19 @@ function normalizeModuleAndLoadMetadata(programPath, exportName, {
|
||||
stringSpecifiers
|
||||
};
|
||||
}
|
||||
|
||||
function getExportSpecifierName(path, stringSpecifiers) {
|
||||
if (path.isIdentifier()) {
|
||||
return path.node.name;
|
||||
} else if (path.isStringLiteral()) {
|
||||
const stringValue = path.node.value;
|
||||
|
||||
if (!(0, _helperValidatorIdentifier.isIdentifierName)(stringValue)) {
|
||||
stringSpecifiers.add(stringValue);
|
||||
}
|
||||
|
||||
return stringValue;
|
||||
} else {
|
||||
throw new Error(`Expected export specifier to be either Identifier or StringLiteral, got ${path.node.type}`);
|
||||
}
|
||||
}
|
||||
|
||||
function assertExportSpecifier(path) {
|
||||
if (path.isExportSpecifier()) {
|
||||
return;
|
||||
@@ -121,11 +105,9 @@ function getModuleMetadata(programPath, {
|
||||
}, stringSpecifiers) {
|
||||
const localData = getLocalExportMetadata(programPath, initializeReexports, stringSpecifiers);
|
||||
const sourceData = new Map();
|
||||
|
||||
const getData = sourceNode => {
|
||||
const source = sourceNode.value;
|
||||
let data = sourceData.get(source);
|
||||
|
||||
if (!data) {
|
||||
data = {
|
||||
name: programPath.scope.generateUidIdentifier((0, _path.basename)(source, (0, _path.extname)(source))).name,
|
||||
@@ -141,10 +123,8 @@ function getModuleMetadata(programPath, {
|
||||
};
|
||||
sourceData.set(source, data);
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
let hasExports = false;
|
||||
programPath.get("body").forEach(child => {
|
||||
if (child.isImportDeclaration()) {
|
||||
@@ -155,7 +135,6 @@ function getModuleMetadata(programPath, {
|
||||
const localName = spec.get("local").node.name;
|
||||
data.imports.set(localName, "default");
|
||||
const reexport = localData.get(localName);
|
||||
|
||||
if (reexport) {
|
||||
localData.delete(localName);
|
||||
reexport.names.forEach(name => {
|
||||
@@ -166,7 +145,6 @@ function getModuleMetadata(programPath, {
|
||||
const localName = spec.get("local").node.name;
|
||||
data.importsNamespace.add(localName);
|
||||
const reexport = localData.get(localName);
|
||||
|
||||
if (reexport) {
|
||||
localData.delete(localName);
|
||||
reexport.names.forEach(name => {
|
||||
@@ -178,7 +156,6 @@ function getModuleMetadata(programPath, {
|
||||
const localName = spec.get("local").node.name;
|
||||
data.imports.set(localName, importName);
|
||||
const reexport = localData.get(localName);
|
||||
|
||||
if (reexport) {
|
||||
localData.delete(localName);
|
||||
reexport.names.forEach(name => {
|
||||
@@ -203,7 +180,6 @@ function getModuleMetadata(programPath, {
|
||||
const importName = getExportSpecifierName(spec.get("local"), stringSpecifiers);
|
||||
const exportName = getExportSpecifierName(spec.get("exported"), stringSpecifiers);
|
||||
data.reexports.set(exportName, importName);
|
||||
|
||||
if (exportName === "__esModule") {
|
||||
throw spec.get("exported").buildCodeFrameError('Illegal export "__esModule".');
|
||||
}
|
||||
@@ -212,35 +188,28 @@ function getModuleMetadata(programPath, {
|
||||
hasExports = true;
|
||||
}
|
||||
});
|
||||
|
||||
for (const metadata of sourceData.values()) {
|
||||
let needsDefault = false;
|
||||
let needsNamed = false;
|
||||
|
||||
if (metadata.importsNamespace.size > 0) {
|
||||
needsDefault = true;
|
||||
needsNamed = true;
|
||||
}
|
||||
|
||||
if (metadata.reexportAll) {
|
||||
needsNamed = true;
|
||||
}
|
||||
|
||||
for (const importName of metadata.imports.values()) {
|
||||
if (importName === "default") needsDefault = true;else needsNamed = true;
|
||||
}
|
||||
|
||||
for (const importName of metadata.reexports.values()) {
|
||||
if (importName === "default") needsDefault = true;else needsNamed = true;
|
||||
}
|
||||
|
||||
if (needsDefault && needsNamed) {
|
||||
metadata.interop = "namespace";
|
||||
} else if (needsDefault) {
|
||||
metadata.interop = "default";
|
||||
}
|
||||
}
|
||||
|
||||
for (const [source, metadata] of sourceData) {
|
||||
if (lazy !== false && !(isSideEffectImport(metadata) || metadata.reexportAll)) {
|
||||
if (lazy === true) {
|
||||
@@ -254,26 +223,22 @@ function getModuleMetadata(programPath, {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
hasExports,
|
||||
local: localData,
|
||||
source: sourceData
|
||||
};
|
||||
}
|
||||
|
||||
function getLocalExportMetadata(programPath, initializeReexports, stringSpecifiers) {
|
||||
const bindingKindLookup = new Map();
|
||||
programPath.get("body").forEach(child => {
|
||||
let kind;
|
||||
|
||||
if (child.isImportDeclaration()) {
|
||||
kind = "import";
|
||||
} else {
|
||||
if (child.isExportDefaultDeclaration()) {
|
||||
child = child.get("declaration");
|
||||
}
|
||||
|
||||
if (child.isExportNamedDeclaration()) {
|
||||
if (child.node.declaration) {
|
||||
child = child.get("declaration");
|
||||
@@ -285,7 +250,6 @@ function getLocalExportMetadata(programPath, initializeReexports, stringSpecifie
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (child.isFunctionDeclaration()) {
|
||||
kind = "hoisted";
|
||||
} else if (child.isClassDeclaration()) {
|
||||
@@ -300,34 +264,27 @@ function getLocalExportMetadata(programPath, initializeReexports, stringSpecifie
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Object.keys(child.getOuterBindingIdentifiers()).forEach(name => {
|
||||
bindingKindLookup.set(name, kind);
|
||||
});
|
||||
});
|
||||
const localMetadata = new Map();
|
||||
|
||||
const getLocalMetadata = idPath => {
|
||||
const localName = idPath.node.name;
|
||||
let metadata = localMetadata.get(localName);
|
||||
|
||||
if (!metadata) {
|
||||
const kind = bindingKindLookup.get(localName);
|
||||
|
||||
if (kind === undefined) {
|
||||
throw idPath.buildCodeFrameError(`Exporting local "${localName}", which is not declared.`);
|
||||
}
|
||||
|
||||
metadata = {
|
||||
names: [],
|
||||
kind
|
||||
};
|
||||
localMetadata.set(localName, metadata);
|
||||
}
|
||||
|
||||
return metadata;
|
||||
};
|
||||
|
||||
programPath.get("body").forEach(child => {
|
||||
if (child.isExportNamedDeclaration() && (initializeReexports || !child.node.source)) {
|
||||
if (child.node.declaration) {
|
||||
@@ -337,7 +294,6 @@ function getLocalExportMetadata(programPath, initializeReexports, stringSpecifie
|
||||
if (name === "__esModule") {
|
||||
throw declaration.buildCodeFrameError('Illegal export "__esModule".');
|
||||
}
|
||||
|
||||
getLocalMetadata(ids[name]).names.push(name);
|
||||
});
|
||||
} else {
|
||||
@@ -346,17 +302,14 @@ function getLocalExportMetadata(programPath, initializeReexports, stringSpecifie
|
||||
const exported = spec.get("exported");
|
||||
const localMetadata = getLocalMetadata(local);
|
||||
const exportName = getExportSpecifierName(exported, stringSpecifiers);
|
||||
|
||||
if (exportName === "__esModule") {
|
||||
throw exported.buildCodeFrameError('Illegal export "__esModule".');
|
||||
}
|
||||
|
||||
localMetadata.names.push(exportName);
|
||||
});
|
||||
}
|
||||
} else if (child.isExportDefaultDeclaration()) {
|
||||
const declaration = child.get("declaration");
|
||||
|
||||
if (declaration.isFunctionDeclaration() || declaration.isClassDeclaration()) {
|
||||
getLocalMetadata(declaration.get("id")).names.push("default");
|
||||
} else {
|
||||
@@ -373,7 +326,6 @@ function nameAnonymousExports(programPath) {
|
||||
(0, _helperSplitExportDeclaration.default)(child);
|
||||
});
|
||||
}
|
||||
|
||||
function removeModuleDeclarations(programPath) {
|
||||
programPath.get("body").forEach(child => {
|
||||
if (child.isImportDeclaration()) {
|
||||
@@ -387,7 +339,6 @@ function removeModuleDeclarations(programPath) {
|
||||
}
|
||||
} else if (child.isExportDefaultDeclaration()) {
|
||||
const declaration = child.get("declaration");
|
||||
|
||||
if (declaration.isFunctionDeclaration() || declaration.isClassDeclaration()) {
|
||||
declaration._blockHoist = child.node._blockHoist;
|
||||
child.replaceWith(declaration);
|
||||
|
||||
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = rewriteLiveReferences;
|
||||
|
||||
var _assert = require("assert");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var _template = require("@babel/template");
|
||||
|
||||
var _helperSimpleAccess = require("@babel/helper-simple-access");
|
||||
|
||||
const {
|
||||
assignmentExpression,
|
||||
callExpression,
|
||||
@@ -31,7 +26,6 @@ const {
|
||||
variableDeclaration,
|
||||
variableDeclarator
|
||||
} = _t;
|
||||
|
||||
function isInType(path) {
|
||||
do {
|
||||
switch (path.parent.type) {
|
||||
@@ -41,45 +35,35 @@ function isInType(path) {
|
||||
case "TypeAnnotation":
|
||||
case "TypeAlias":
|
||||
return true;
|
||||
|
||||
case "ExportSpecifier":
|
||||
return path.parentPath.parent.exportKind === "type";
|
||||
|
||||
default:
|
||||
if (path.parentPath.isStatement() || path.parentPath.isExpression()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
} while (path = path.parentPath);
|
||||
}
|
||||
|
||||
function rewriteLiveReferences(programPath, metadata) {
|
||||
const imported = new Map();
|
||||
const exported = new Map();
|
||||
|
||||
const requeueInParent = path => {
|
||||
programPath.requeue(path);
|
||||
};
|
||||
|
||||
for (const [source, data] of metadata.source) {
|
||||
for (const [localName, importName] of data.imports) {
|
||||
imported.set(localName, [source, importName, null]);
|
||||
}
|
||||
|
||||
for (const localName of data.importsNamespace) {
|
||||
imported.set(localName, [source, null, localName]);
|
||||
}
|
||||
}
|
||||
|
||||
for (const [local, data] of metadata.local) {
|
||||
let exportMeta = exported.get(local);
|
||||
|
||||
if (!exportMeta) {
|
||||
exportMeta = [];
|
||||
exported.set(local, exportMeta);
|
||||
}
|
||||
|
||||
exportMeta.push(...data.names);
|
||||
}
|
||||
|
||||
@@ -89,8 +73,12 @@ function rewriteLiveReferences(programPath, metadata) {
|
||||
scope: programPath.scope,
|
||||
exported
|
||||
};
|
||||
programPath.traverse(rewriteBindingInitVisitor, rewriteBindingInitVisitorState);
|
||||
(0, _helperSimpleAccess.default)(programPath, new Set([...Array.from(imported.keys()), ...Array.from(exported.keys())]), false);
|
||||
|
||||
programPath.traverse(
|
||||
rewriteBindingInitVisitor, rewriteBindingInitVisitorState);
|
||||
(0, _helperSimpleAccess.default)(programPath,
|
||||
new Set([...Array.from(imported.keys()), ...Array.from(exported.keys())]), false);
|
||||
|
||||
const rewriteReferencesVisitorState = {
|
||||
seen: new WeakSet(),
|
||||
metadata,
|
||||
@@ -100,22 +88,18 @@ function rewriteLiveReferences(programPath, metadata) {
|
||||
exported,
|
||||
buildImportReference: ([source, importName, localName], identNode) => {
|
||||
const meta = metadata.source.get(source);
|
||||
|
||||
if (localName) {
|
||||
if (meta.lazy) {
|
||||
identNode = callExpression(identNode, []);
|
||||
identNode = callExpression(
|
||||
identNode, []);
|
||||
}
|
||||
|
||||
return identNode;
|
||||
}
|
||||
|
||||
let namespace = identifier(meta.name);
|
||||
if (meta.lazy) namespace = callExpression(namespace, []);
|
||||
|
||||
if (importName === "default" && meta.interop === "node-default") {
|
||||
return namespace;
|
||||
}
|
||||
|
||||
const computed = metadata.stringSpecifiers.has(importName);
|
||||
return memberExpression(namespace, computed ? stringLiteral(importName) : identifier(importName), computed);
|
||||
}
|
||||
@@ -127,7 +111,6 @@ const rewriteBindingInitVisitor = {
|
||||
Scope(path) {
|
||||
path.skip();
|
||||
},
|
||||
|
||||
ClassDeclaration(path) {
|
||||
const {
|
||||
requeueInParent,
|
||||
@@ -140,14 +123,13 @@ const rewriteBindingInitVisitor = {
|
||||
if (!id) throw new Error("Expected class to have a name");
|
||||
const localName = id.name;
|
||||
const exportNames = exported.get(localName) || [];
|
||||
|
||||
if (exportNames.length > 0) {
|
||||
const statement = expressionStatement(buildBindingExportAssignmentExpression(metadata, exportNames, identifier(localName), path.scope));
|
||||
const statement = expressionStatement(
|
||||
buildBindingExportAssignmentExpression(metadata, exportNames, identifier(localName), path.scope));
|
||||
statement._blockHoist = path.node._blockHoist;
|
||||
requeueInParent(path.insertAfter(statement)[0]);
|
||||
}
|
||||
},
|
||||
|
||||
VariableDeclaration(path) {
|
||||
const {
|
||||
requeueInParent,
|
||||
@@ -156,26 +138,22 @@ const rewriteBindingInitVisitor = {
|
||||
} = this;
|
||||
Object.keys(path.getOuterBindingIdentifiers()).forEach(localName => {
|
||||
const exportNames = exported.get(localName) || [];
|
||||
|
||||
if (exportNames.length > 0) {
|
||||
const statement = expressionStatement(buildBindingExportAssignmentExpression(metadata, exportNames, identifier(localName), path.scope));
|
||||
const statement = expressionStatement(
|
||||
buildBindingExportAssignmentExpression(metadata, exportNames, identifier(localName), path.scope));
|
||||
statement._blockHoist = path.node._blockHoist;
|
||||
requeueInParent(path.insertAfter(statement)[0]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const buildBindingExportAssignmentExpression = (metadata, exportNames, localExpr, scope) => {
|
||||
const exportsObjectName = metadata.exportName;
|
||||
|
||||
for (let currentScope = scope; currentScope != null; currentScope = currentScope.parent) {
|
||||
if (currentScope.hasOwnBinding(exportsObjectName)) {
|
||||
currentScope.rename(exportsObjectName);
|
||||
}
|
||||
}
|
||||
|
||||
return (exportNames || []).reduce((expr, exportName) => {
|
||||
const {
|
||||
stringSpecifiers
|
||||
@@ -184,7 +162,6 @@ const buildBindingExportAssignmentExpression = (metadata, exportNames, localExpr
|
||||
return assignmentExpression("=", memberExpression(identifier(exportsObjectName), computed ? stringLiteral(exportName) : identifier(exportName), computed), expr);
|
||||
}, localExpr);
|
||||
};
|
||||
|
||||
const buildImportThrow = localName => {
|
||||
return _template.default.expression.ast`
|
||||
(function() {
|
||||
@@ -192,7 +169,6 @@ const buildImportThrow = localName => {
|
||||
})()
|
||||
`;
|
||||
};
|
||||
|
||||
const rewriteReferencesVisitor = {
|
||||
ReferencedIdentifier(path) {
|
||||
const {
|
||||
@@ -206,18 +182,17 @@ const rewriteReferencesVisitor = {
|
||||
seen.add(path.node);
|
||||
const localName = path.node.name;
|
||||
const importData = imported.get(localName);
|
||||
|
||||
if (importData) {
|
||||
if (isInType(path)) {
|
||||
throw path.buildCodeFrameError(`Cannot transform the imported binding "${localName}" since it's also used in a type annotation. ` + `Please strip type annotations using @babel/preset-typescript or @babel/preset-flow.`);
|
||||
}
|
||||
|
||||
const localBinding = path.scope.getBinding(localName);
|
||||
const rootBinding = scope.getBinding(localName);
|
||||
|
||||
if (rootBinding !== localBinding) return;
|
||||
const ref = buildImportReference(importData, path.node);
|
||||
ref.loc = path.node.loc;
|
||||
|
||||
ref.loc = path.node.loc;
|
||||
if ((path.parentPath.isCallExpression({
|
||||
callee: path.node
|
||||
}) || path.parentPath.isOptionalCallExpression({
|
||||
@@ -231,16 +206,17 @@ const rewriteReferencesVisitor = {
|
||||
object,
|
||||
property
|
||||
} = ref;
|
||||
path.replaceWith(jsxMemberExpression(jsxIdentifier(object.name), jsxIdentifier(property.name)));
|
||||
path.replaceWith(jsxMemberExpression(
|
||||
jsxIdentifier(object.name),
|
||||
jsxIdentifier(property.name)));
|
||||
} else {
|
||||
path.replaceWith(ref);
|
||||
}
|
||||
|
||||
requeueInParent(path);
|
||||
|
||||
path.skip();
|
||||
}
|
||||
},
|
||||
|
||||
UpdateExpression(path) {
|
||||
const {
|
||||
scope,
|
||||
@@ -253,19 +229,17 @@ const rewriteReferencesVisitor = {
|
||||
if (seen.has(path.node)) return;
|
||||
seen.add(path.node);
|
||||
const arg = path.get("argument");
|
||||
|
||||
if (arg.isMemberExpression()) return;
|
||||
const update = path.node;
|
||||
|
||||
if (arg.isIdentifier()) {
|
||||
const localName = arg.node.name;
|
||||
|
||||
if (scope.getBinding(localName) !== path.scope.getBinding(localName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const exportedNames = exported.get(localName);
|
||||
const importData = imported.get(localName);
|
||||
|
||||
if ((exportedNames == null ? void 0 : exportedNames.length) > 0 || importData) {
|
||||
if (importData) {
|
||||
path.replaceWith(assignmentExpression(update.operator[0] + "=", buildImportReference(importData, arg.node), buildImportThrow(localName)));
|
||||
@@ -277,11 +251,9 @@ const rewriteReferencesVisitor = {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
requeueInParent(path);
|
||||
path.skip();
|
||||
},
|
||||
|
||||
AssignmentExpression: {
|
||||
exit(path) {
|
||||
const {
|
||||
@@ -295,28 +267,23 @@ const rewriteReferencesVisitor = {
|
||||
if (seen.has(path.node)) return;
|
||||
seen.add(path.node);
|
||||
const left = path.get("left");
|
||||
if (left.isMemberExpression()) return;
|
||||
|
||||
if (left.isMemberExpression()) return;
|
||||
if (left.isIdentifier()) {
|
||||
const localName = left.node.name;
|
||||
|
||||
if (scope.getBinding(localName) !== path.scope.getBinding(localName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const exportedNames = exported.get(localName);
|
||||
const importData = imported.get(localName);
|
||||
|
||||
if ((exportedNames == null ? void 0 : exportedNames.length) > 0 || importData) {
|
||||
_assert(path.node.operator === "=", "Path was not simplified");
|
||||
|
||||
const assignment = path.node;
|
||||
|
||||
if (importData) {
|
||||
assignment.left = buildImportReference(importData, left.node);
|
||||
assignment.right = sequenceExpression([assignment.right, buildImportThrow(localName)]);
|
||||
}
|
||||
|
||||
path.replaceWith(buildBindingExportAssignmentExpression(this.metadata, exportedNames, assignment, path.scope));
|
||||
requeueInParent(path);
|
||||
}
|
||||
@@ -324,7 +291,6 @@ const rewriteReferencesVisitor = {
|
||||
const ids = left.getOuterBindingIdentifiers();
|
||||
const programScopeIds = Object.keys(ids).filter(localName => scope.getBinding(localName) === path.scope.getBinding(localName));
|
||||
const id = programScopeIds.find(localName => imported.has(localName));
|
||||
|
||||
if (id) {
|
||||
path.node.right = sequenceExpression([path.node.right, buildImportThrow(id)]);
|
||||
}
|
||||
@@ -332,28 +298,22 @@ const rewriteReferencesVisitor = {
|
||||
const items = [];
|
||||
programScopeIds.forEach(localName => {
|
||||
const exportedNames = exported.get(localName) || [];
|
||||
|
||||
if (exportedNames.length > 0) {
|
||||
items.push(buildBindingExportAssignmentExpression(this.metadata, exportedNames, identifier(localName), path.scope));
|
||||
}
|
||||
});
|
||||
|
||||
if (items.length > 0) {
|
||||
let node = sequenceExpression(items);
|
||||
|
||||
if (path.parentPath.isExpressionStatement()) {
|
||||
node = expressionStatement(node);
|
||||
node._blockHoist = path.parentPath.node._blockHoist;
|
||||
}
|
||||
|
||||
const statement = path.insertAfter(node)[0];
|
||||
requeueInParent(statement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"ForOfStatement|ForInStatement"(path) {
|
||||
const {
|
||||
scope,
|
||||
@@ -367,48 +327,39 @@ const rewriteReferencesVisitor = {
|
||||
imported,
|
||||
scope: programScope
|
||||
} = this;
|
||||
|
||||
if (!isVariableDeclaration(left)) {
|
||||
let didTransformExport = false,
|
||||
importConstViolationName;
|
||||
importConstViolationName;
|
||||
const loopBodyScope = path.get("body").scope;
|
||||
|
||||
for (const name of Object.keys(getOuterBindingIdentifiers(left))) {
|
||||
if (programScope.getBinding(name) === scope.getBinding(name)) {
|
||||
if (exported.has(name)) {
|
||||
didTransformExport = true;
|
||||
|
||||
if (loopBodyScope.hasOwnBinding(name)) {
|
||||
loopBodyScope.rename(name);
|
||||
}
|
||||
}
|
||||
|
||||
if (imported.has(name) && !importConstViolationName) {
|
||||
importConstViolationName = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!didTransformExport && !importConstViolationName) {
|
||||
return;
|
||||
}
|
||||
|
||||
path.ensureBlock();
|
||||
const bodyPath = path.get("body");
|
||||
const newLoopId = scope.generateUidIdentifierBasedOnNode(left);
|
||||
path.get("left").replaceWith(variableDeclaration("let", [variableDeclarator(cloneNode(newLoopId))]));
|
||||
scope.registerDeclaration(path.get("left"));
|
||||
|
||||
if (didTransformExport) {
|
||||
bodyPath.unshiftContainer("body", expressionStatement(assignmentExpression("=", left, newLoopId)));
|
||||
}
|
||||
|
||||
if (importConstViolationName) {
|
||||
bodyPath.unshiftContainer("body", expressionStatement(buildImportThrow(importConstViolationName)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//# sourceMappingURL=rewrite-live-references.js.map
|
||||
|
||||
@@ -4,29 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = rewriteThis;
|
||||
|
||||
var _helperEnvironmentVisitor = require("@babel/helper-environment-visitor");
|
||||
|
||||
var _traverse = require("@babel/traverse");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
numericLiteral,
|
||||
unaryExpression
|
||||
} = _t;
|
||||
|
||||
const rewriteThisVisitor = _traverse.default.visitors.merge([_helperEnvironmentVisitor.default, {
|
||||
ThisExpression(path) {
|
||||
path.replaceWith(unaryExpression("void", numericLiteral(0), true));
|
||||
}
|
||||
}]);
|
||||
function rewriteThis(programPath) {
|
||||
(0, _traverse.default)(programPath.node, Object.assign({}, rewriteThisVisitor, {
|
||||
noScope: true
|
||||
}));
|
||||
}
|
||||
|
||||
const rewriteThisVisitor = _traverse.default.visitors.merge([_helperEnvironmentVisitor.default, {
|
||||
ThisExpression(path) {
|
||||
path.replaceWith(unaryExpression("void", numericLiteral(0), true));
|
||||
}
|
||||
|
||||
}]);
|
||||
|
||||
//# sourceMappingURL=rewrite-this.js.map
|
||||
|
||||
8
tools/node_modules/eslint/node_modules/@babel/helper-module-transforms/package.json
generated
vendored
8
tools/node_modules/eslint/node_modules/@babel/helper-module-transforms/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-module-transforms",
|
||||
"version": "7.19.6",
|
||||
"version": "7.20.2",
|
||||
"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.19.4",
|
||||
"@babel/helper-simple-access": "^7.20.2",
|
||||
"@babel/helper-split-export-declaration": "^7.18.6",
|
||||
"@babel/helper-validator-identifier": "^7.19.1",
|
||||
"@babel/template": "^7.18.10",
|
||||
"@babel/traverse": "^7.19.6",
|
||||
"@babel/types": "^7.19.4"
|
||||
"@babel/traverse": "^7.20.1",
|
||||
"@babel/types": "^7.20.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
|
||||
50
tools/node_modules/eslint/node_modules/@babel/helper-plugin-utils/lib/index.js
generated
vendored
50
tools/node_modules/eslint/node_modules/@babel/helper-plugin-utils/lib/index.js
generated
vendored
@@ -5,27 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
exports.declare = declare;
|
||||
exports.declarePreset = void 0;
|
||||
|
||||
function declare(builder) {
|
||||
return (api, options, dirname) => {
|
||||
var _clonedApi2;
|
||||
|
||||
let clonedApi;
|
||||
|
||||
for (const name of Object.keys(apiPolyfills)) {
|
||||
var _clonedApi;
|
||||
|
||||
if (api[name]) continue;
|
||||
clonedApi = (_clonedApi = clonedApi) != null ? _clonedApi : copyApiObject(api);
|
||||
clonedApi[name] = apiPolyfills[name](clonedApi);
|
||||
}
|
||||
|
||||
return builder((_clonedApi2 = clonedApi) != null ? _clonedApi2 : api, options || {}, dirname);
|
||||
};
|
||||
}
|
||||
|
||||
const declarePreset = declare;
|
||||
exports.declarePreset = declarePreset;
|
||||
const apiPolyfills = {
|
||||
assertVersion: api => range => {
|
||||
throwVersionError(range, api.version);
|
||||
@@ -37,56 +16,59 @@ const apiPolyfills = {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
function declare(builder) {
|
||||
return (api, options, dirname) => {
|
||||
var _clonedApi2;
|
||||
let clonedApi;
|
||||
for (const name of Object.keys(apiPolyfills)) {
|
||||
var _clonedApi;
|
||||
if (api[name]) continue;
|
||||
|
||||
clonedApi = (_clonedApi = clonedApi) != null ? _clonedApi : copyApiObject(api);
|
||||
clonedApi[name] = apiPolyfills[name](clonedApi);
|
||||
}
|
||||
|
||||
return builder((_clonedApi2 = clonedApi) != null ? _clonedApi2 : api, options || {}, dirname);
|
||||
};
|
||||
}
|
||||
const declarePreset = declare;
|
||||
exports.declarePreset = declarePreset;
|
||||
function copyApiObject(api) {
|
||||
let proto = null;
|
||||
|
||||
if (typeof api.version === "string" && /^7\./.test(api.version)) {
|
||||
proto = Object.getPrototypeOf(api);
|
||||
|
||||
if (proto && (!has(proto, "version") || !has(proto, "transform") || !has(proto, "template") || !has(proto, "types"))) {
|
||||
proto = null;
|
||||
}
|
||||
}
|
||||
|
||||
return Object.assign({}, proto, api);
|
||||
}
|
||||
|
||||
function has(obj, key) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, key);
|
||||
}
|
||||
|
||||
function throwVersionError(range, version) {
|
||||
if (typeof range === "number") {
|
||||
if (!Number.isInteger(range)) {
|
||||
throw new Error("Expected string or integer value.");
|
||||
}
|
||||
|
||||
range = `^${range}.0.0-0`;
|
||||
}
|
||||
|
||||
if (typeof range !== "string") {
|
||||
throw new Error("Expected string or integer value.");
|
||||
}
|
||||
|
||||
const limit = Error.stackTraceLimit;
|
||||
|
||||
if (typeof limit === "number" && limit < 25) {
|
||||
Error.stackTraceLimit = 25;
|
||||
}
|
||||
|
||||
let err;
|
||||
|
||||
if (version.slice(0, 2) === "7.") {
|
||||
err = new Error(`Requires Babel "^7.0.0-beta.41", but was loaded with "${version}". ` + `You'll need to update your @babel/core version.`);
|
||||
} else {
|
||||
err = new Error(`Requires Babel "${range}", but was loaded with "${version}". ` + `If you are sure you have a compatible version of @babel/core, ` + `it is likely that something in your build process is loading the ` + `wrong version. Inspect the stack trace of this error to look for ` + `the first entry that doesn't mention "@babel/core" or "babel-core" ` + `to see what is calling Babel.`);
|
||||
}
|
||||
|
||||
if (typeof limit === "number") {
|
||||
Error.stackTraceLimit = limit;
|
||||
}
|
||||
|
||||
throw Object.assign(err, {
|
||||
code: "BABEL_VERSION_UNSUPPORTED",
|
||||
version,
|
||||
|
||||
2
tools/node_modules/eslint/node_modules/@babel/helper-plugin-utils/package.json
generated
vendored
2
tools/node_modules/eslint/node_modules/@babel/helper-plugin-utils/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-plugin-utils",
|
||||
"version": "7.19.0",
|
||||
"version": "7.20.2",
|
||||
"description": "General utilities for plugins to use",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-helper-plugin-utils",
|
||||
|
||||
39
tools/node_modules/eslint/node_modules/@babel/helper-simple-access/lib/index.js
generated
vendored
39
tools/node_modules/eslint/node_modules/@babel/helper-simple-access/lib/index.js
generated
vendored
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = simplifyAccess;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
LOGICAL_OPERATORS,
|
||||
assignmentExpression,
|
||||
@@ -18,16 +16,6 @@ const {
|
||||
sequenceExpression,
|
||||
unaryExpression
|
||||
} = _t;
|
||||
|
||||
function simplifyAccess(path, bindingNames, includeUpdateExpression = true) {
|
||||
path.traverse(simpleAssignmentVisitor, {
|
||||
scope: path.scope,
|
||||
bindingNames,
|
||||
seen: new WeakSet(),
|
||||
includeUpdateExpression
|
||||
});
|
||||
}
|
||||
|
||||
const simpleAssignmentVisitor = {
|
||||
UpdateExpression: {
|
||||
exit(path) {
|
||||
@@ -36,11 +24,9 @@ const simpleAssignmentVisitor = {
|
||||
bindingNames,
|
||||
includeUpdateExpression
|
||||
} = this;
|
||||
|
||||
if (!includeUpdateExpression) {
|
||||
return;
|
||||
}
|
||||
|
||||
const arg = path.get("argument");
|
||||
if (!arg.isIdentifier()) return;
|
||||
const localName = arg.node.name;
|
||||
@@ -49,7 +35,6 @@ const simpleAssignmentVisitor = {
|
||||
if (scope.getBinding(localName) !== path.scope.getBinding(localName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (path.parentPath.isExpressionStatement() && !path.isCompletionRecord()) {
|
||||
const operator = path.node.operator == "++" ? "+=" : "-=";
|
||||
path.replaceWith(assignmentExpression(operator, arg.node, numericLiteral(1)));
|
||||
@@ -61,11 +46,12 @@ const simpleAssignmentVisitor = {
|
||||
path.scope.push({
|
||||
id: old
|
||||
});
|
||||
const binary = binaryExpression(path.node.operator[0], identifier(varName), numericLiteral(1));
|
||||
const binary = binaryExpression(path.node.operator[0], identifier(varName),
|
||||
numericLiteral(1));
|
||||
|
||||
path.replaceWith(sequenceExpression([assignmentExpression("=", identifier(varName), unaryExpression("+", arg.node)), assignmentExpression("=", cloneNode(arg.node), binary), identifier(varName)]));
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
AssignmentExpression: {
|
||||
exit(path) {
|
||||
@@ -79,24 +65,33 @@ const simpleAssignmentVisitor = {
|
||||
seen.add(path.node);
|
||||
const left = path.get("left");
|
||||
if (!left.isIdentifier()) return;
|
||||
|
||||
const localName = left.node.name;
|
||||
if (!bindingNames.has(localName)) return;
|
||||
|
||||
if (scope.getBinding(localName) !== path.scope.getBinding(localName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const operator = path.node.operator.slice(0, -1);
|
||||
|
||||
if (LOGICAL_OPERATORS.includes(operator)) {
|
||||
path.replaceWith(logicalExpression(operator, path.node.left, assignmentExpression("=", cloneNode(path.node.left), path.node.right)));
|
||||
path.replaceWith(logicalExpression(
|
||||
operator, path.node.left, assignmentExpression("=", cloneNode(path.node.left), path.node.right)));
|
||||
} else {
|
||||
path.node.right = binaryExpression(operator, cloneNode(path.node.left), path.node.right);
|
||||
path.node.right = binaryExpression(
|
||||
operator, cloneNode(path.node.left), path.node.right);
|
||||
path.node.operator = "=";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
function simplifyAccess(path, bindingNames,
|
||||
includeUpdateExpression = true) {
|
||||
path.traverse(simpleAssignmentVisitor, {
|
||||
scope: path.scope,
|
||||
bindingNames,
|
||||
seen: new WeakSet(),
|
||||
includeUpdateExpression
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
8
tools/node_modules/eslint/node_modules/@babel/helper-simple-access/package.json
generated
vendored
8
tools/node_modules/eslint/node_modules/@babel/helper-simple-access/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-simple-access",
|
||||
"version": "7.19.4",
|
||||
"version": "7.20.2",
|
||||
"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,11 +15,11 @@
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.19.4"
|
||||
"@babel/types": "^7.20.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.19.3",
|
||||
"@babel/traverse": "^7.19.4"
|
||||
"@babel/core": "^7.20.2",
|
||||
"@babel/traverse": "^7.20.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
|
||||
5
tools/node_modules/eslint/node_modules/@babel/helpers/lib/helpers-generated.js
generated
vendored
5
tools/node_modules/eslint/node_modules/@babel/helpers/lib/helpers-generated.js
generated
vendored
File diff suppressed because one or more lines are too long
15
tools/node_modules/eslint/node_modules/@babel/helpers/lib/helpers.js
generated
vendored
15
tools/node_modules/eslint/node_modules/@babel/helpers/lib/helpers.js
generated
vendored
@@ -4,22 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _template = require("@babel/template");
|
||||
|
||||
var _helpersGenerated = require("./helpers-generated");
|
||||
|
||||
const helpers = Object.assign({
|
||||
__proto__: null
|
||||
}, _helpersGenerated.default);
|
||||
var _default = helpers;
|
||||
exports.default = _default;
|
||||
|
||||
const helper = minVersion => tpl => ({
|
||||
minVersion,
|
||||
ast: () => _template.default.program.ast(tpl)
|
||||
});
|
||||
|
||||
{
|
||||
helpers.AwaitValue = helper("7.0.0-beta.0")`
|
||||
export default function _AwaitValue(value) {
|
||||
@@ -153,6 +148,7 @@ helpers.defineProperty = helper("7.0.0-beta.0")`
|
||||
return obj;
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.extends = helper("7.0.0-beta.0")`
|
||||
export default function _extends() {
|
||||
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
||||
@@ -170,6 +166,7 @@ helpers.extends = helper("7.0.0-beta.0")`
|
||||
return _extends.apply(this, arguments);
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.objectSpread = helper("7.0.0-beta.0")`
|
||||
import defineProperty from "defineProperty";
|
||||
|
||||
@@ -219,6 +216,7 @@ helpers.inheritsLoose = helper("7.0.0-beta.0")`
|
||||
setPrototypeOf(subClass, superClass);
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.getPrototypeOf = helper("7.0.0-beta.0")`
|
||||
export default function _getPrototypeOf(o) {
|
||||
_getPrototypeOf = Object.setPrototypeOf
|
||||
@@ -267,6 +265,7 @@ helpers.isNativeReflectConstruct = helper("7.9.0")`
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.construct = helper("7.0.0-beta.0")`
|
||||
import setPrototypeOf from "setPrototypeOf";
|
||||
import isNativeReflectConstruct from "isNativeReflectConstruct";
|
||||
@@ -297,6 +296,7 @@ helpers.isNativeFunction = helper("7.0.0-beta.0")`
|
||||
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.wrapNativeSuper = helper("7.0.0-beta.0")`
|
||||
import getPrototypeOf from "getPrototypeOf";
|
||||
import setPrototypeOf from "setPrototypeOf";
|
||||
@@ -465,6 +465,7 @@ helpers.possibleConstructorReturn = helper("7.0.0-beta.0")`
|
||||
return assertThisInitialized(self);
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.createSuper = helper("7.9.0")`
|
||||
import getPrototypeOf from "getPrototypeOf";
|
||||
import isNativeReflectConstruct from "isNativeReflectConstruct";
|
||||
@@ -498,6 +499,7 @@ helpers.superPropBase = helper("7.0.0-beta.0")`
|
||||
return object;
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.get = helper("7.0.0-beta.0")`
|
||||
import superPropBase from "superPropBase";
|
||||
|
||||
@@ -915,6 +917,7 @@ helpers.toPropertyKey = helper("7.1.5")`
|
||||
return typeof key === "symbol" ? key : String(key);
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.initializerWarningHelper = helper("7.0.0-beta.0")`
|
||||
export default function _initializerWarningHelper(descriptor, context){
|
||||
throw new Error(
|
||||
@@ -923,6 +926,7 @@ helpers.initializerWarningHelper = helper("7.0.0-beta.0")`
|
||||
);
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.initializerDefineProperty = helper("7.0.0-beta.0")`
|
||||
export default function _initializerDefineProperty(target, property, descriptor, context){
|
||||
if (!descriptor) return;
|
||||
@@ -935,6 +939,7 @@ helpers.initializerDefineProperty = helper("7.0.0-beta.0")`
|
||||
});
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.applyDecoratedDescriptor = helper("7.0.0-beta.0")`
|
||||
export default function _applyDecoratedDescriptor(target, property, decorators, descriptor, context){
|
||||
var desc = {};
|
||||
|
||||
16
tools/node_modules/eslint/node_modules/@babel/helpers/lib/helpers/AsyncGenerator.js
generated
vendored
16
tools/node_modules/eslint/node_modules/@babel/helpers/lib/helpers/AsyncGenerator.js
generated
vendored
@@ -4,12 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = AsyncGenerator;
|
||||
|
||||
var _OverloadYield = require("OverloadYield");
|
||||
|
||||
function AsyncGenerator(gen) {
|
||||
var front, back;
|
||||
|
||||
function send(key, arg) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var request = {
|
||||
@@ -19,7 +17,6 @@ function AsyncGenerator(gen) {
|
||||
reject: reject,
|
||||
next: null
|
||||
};
|
||||
|
||||
if (back) {
|
||||
back = back.next = request;
|
||||
} else {
|
||||
@@ -28,7 +25,6 @@ function AsyncGenerator(gen) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function resume(key, arg) {
|
||||
try {
|
||||
var result = gen[key](arg);
|
||||
@@ -37,14 +33,12 @@ function AsyncGenerator(gen) {
|
||||
Promise.resolve(overloaded ? value.v : value).then(function (arg) {
|
||||
if (overloaded) {
|
||||
var nextKey = key === "return" ? "return" : "next";
|
||||
|
||||
if (!value.k || arg.done) {
|
||||
return resume(nextKey, arg);
|
||||
} else {
|
||||
arg = gen[nextKey](arg).value;
|
||||
}
|
||||
}
|
||||
|
||||
settle(result.done ? "return" : "normal", arg);
|
||||
}, function (err) {
|
||||
resume("throw", err);
|
||||
@@ -53,7 +47,6 @@ function AsyncGenerator(gen) {
|
||||
settle("throw", err);
|
||||
}
|
||||
}
|
||||
|
||||
function settle(type, value) {
|
||||
switch (type) {
|
||||
case "return":
|
||||
@@ -62,11 +55,9 @@ function AsyncGenerator(gen) {
|
||||
done: true
|
||||
});
|
||||
break;
|
||||
|
||||
case "throw":
|
||||
front.reject(value);
|
||||
break;
|
||||
|
||||
default:
|
||||
front.resolve({
|
||||
value: value,
|
||||
@@ -74,35 +65,28 @@ function AsyncGenerator(gen) {
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
front = front.next;
|
||||
|
||||
if (front) {
|
||||
resume(front.key, front.arg);
|
||||
} else {
|
||||
back = null;
|
||||
}
|
||||
}
|
||||
|
||||
this._invoke = send;
|
||||
|
||||
if (typeof gen.return !== "function") {
|
||||
this.return = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
AsyncGenerator.prototype[typeof Symbol === "function" && Symbol.asyncIterator || "@@asyncIterator"] = function () {
|
||||
return this;
|
||||
};
|
||||
|
||||
AsyncGenerator.prototype.next = function (arg) {
|
||||
return this._invoke("next", arg);
|
||||
};
|
||||
|
||||
AsyncGenerator.prototype.throw = function (arg) {
|
||||
return this._invoke("throw", arg);
|
||||
};
|
||||
|
||||
AsyncGenerator.prototype.return = function (arg) {
|
||||
return this._invoke("return", arg);
|
||||
};
|
||||
|
||||
83
tools/node_modules/eslint/node_modules/@babel/helpers/lib/helpers/applyDecs.js
generated
vendored
83
tools/node_modules/eslint/node_modules/@babel/helpers/lib/helpers/applyDecs.js
generated
vendored
@@ -12,16 +12,13 @@ function old_createMetadataMethodsForProperty(metadataMap, kind, property, decor
|
||||
old_assertMetadataKey(key);
|
||||
var metadataForKey = metadataMap[key];
|
||||
if (metadataForKey === void 0) return void 0;
|
||||
|
||||
if (kind === 1) {
|
||||
var pub = metadataForKey.public;
|
||||
|
||||
if (pub !== void 0) {
|
||||
return pub[property];
|
||||
}
|
||||
} else if (kind === 2) {
|
||||
var priv = metadataForKey.private;
|
||||
|
||||
if (priv !== void 0) {
|
||||
return priv.get(property);
|
||||
}
|
||||
@@ -33,26 +30,20 @@ function old_createMetadataMethodsForProperty(metadataMap, kind, property, decor
|
||||
old_assertNotFinished(decoratorFinishedRef, "setMetadata");
|
||||
old_assertMetadataKey(key);
|
||||
var metadataForKey = metadataMap[key];
|
||||
|
||||
if (metadataForKey === void 0) {
|
||||
metadataForKey = metadataMap[key] = {};
|
||||
}
|
||||
|
||||
if (kind === 1) {
|
||||
var pub = metadataForKey.public;
|
||||
|
||||
if (pub === void 0) {
|
||||
pub = metadataForKey.public = {};
|
||||
}
|
||||
|
||||
pub[property] = value;
|
||||
} else if (kind === 2) {
|
||||
var priv = metadataForKey.priv;
|
||||
|
||||
if (priv === void 0) {
|
||||
priv = metadataForKey.private = new Map();
|
||||
}
|
||||
|
||||
priv.set(property, value);
|
||||
} else {
|
||||
metadataForKey.constructor = value;
|
||||
@@ -60,48 +51,37 @@ function old_createMetadataMethodsForProperty(metadataMap, kind, property, decor
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function old_convertMetadataMapToFinal(obj, metadataMap) {
|
||||
var parentMetadataMap = obj[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
||||
var metadataKeys = Object.getOwnPropertySymbols(metadataMap);
|
||||
if (metadataKeys.length === 0) return;
|
||||
|
||||
for (var i = 0; i < metadataKeys.length; i++) {
|
||||
var key = metadataKeys[i];
|
||||
var metaForKey = metadataMap[key];
|
||||
var parentMetaForKey = parentMetadataMap ? parentMetadataMap[key] : null;
|
||||
var pub = metaForKey.public;
|
||||
var parentPub = parentMetaForKey ? parentMetaForKey.public : null;
|
||||
|
||||
if (pub && parentPub) {
|
||||
Object.setPrototypeOf(pub, parentPub);
|
||||
}
|
||||
|
||||
var priv = metaForKey.private;
|
||||
|
||||
if (priv) {
|
||||
var privArr = Array.from(priv.values());
|
||||
var parentPriv = parentMetaForKey ? parentMetaForKey.private : null;
|
||||
|
||||
if (parentPriv) {
|
||||
privArr = privArr.concat(parentPriv);
|
||||
}
|
||||
|
||||
metaForKey.private = privArr;
|
||||
}
|
||||
|
||||
if (parentMetaForKey) {
|
||||
Object.setPrototypeOf(metaForKey, parentMetaForKey);
|
||||
}
|
||||
}
|
||||
|
||||
if (parentMetadataMap) {
|
||||
Object.setPrototypeOf(metadataMap, parentMetadataMap);
|
||||
}
|
||||
|
||||
obj[Symbol.metadata || Symbol.for("Symbol.metadata")] = metadataMap;
|
||||
}
|
||||
|
||||
function old_createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
||||
return function addInitializer(initializer) {
|
||||
old_assertNotFinished(decoratorFinishedRef, "addInitializer");
|
||||
@@ -109,31 +89,24 @@ function old_createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
||||
initializers.push(initializer);
|
||||
};
|
||||
}
|
||||
|
||||
function old_memberDec(dec, name, desc, metadataMap, initializers, kind, isStatic, isPrivate, value) {
|
||||
var kindStr;
|
||||
|
||||
switch (kind) {
|
||||
case 1:
|
||||
kindStr = "accessor";
|
||||
break;
|
||||
|
||||
case 2:
|
||||
kindStr = "method";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
kindStr = "getter";
|
||||
break;
|
||||
|
||||
case 4:
|
||||
kindStr = "setter";
|
||||
break;
|
||||
|
||||
default:
|
||||
kindStr = "field";
|
||||
}
|
||||
|
||||
var ctx = {
|
||||
kind: kindStr,
|
||||
name: isPrivate ? "#" + name : name,
|
||||
@@ -143,18 +116,14 @@ function old_memberDec(dec, name, desc, metadataMap, initializers, kind, isStati
|
||||
var decoratorFinishedRef = {
|
||||
v: false
|
||||
};
|
||||
|
||||
if (kind !== 0) {
|
||||
ctx.addInitializer = old_createAddInitializerMethod(initializers, decoratorFinishedRef);
|
||||
}
|
||||
|
||||
var metadataKind, metadataName;
|
||||
|
||||
if (isPrivate) {
|
||||
metadataKind = 2;
|
||||
metadataName = Symbol(name);
|
||||
var access = {};
|
||||
|
||||
if (kind === 0) {
|
||||
access.get = desc.get;
|
||||
access.set = desc.set;
|
||||
@@ -168,71 +137,58 @@ function old_memberDec(dec, name, desc, metadataMap, initializers, kind, isStati
|
||||
return desc.get.call(this);
|
||||
};
|
||||
}
|
||||
|
||||
if (kind === 1 || kind === 4) {
|
||||
access.set = function (v) {
|
||||
desc.set.call(this, v);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
ctx.access = access;
|
||||
} else {
|
||||
metadataKind = 1;
|
||||
metadataName = name;
|
||||
}
|
||||
|
||||
try {
|
||||
return dec(value, Object.assign(ctx, old_createMetadataMethodsForProperty(metadataMap, metadataKind, metadataName, decoratorFinishedRef)));
|
||||
} finally {
|
||||
decoratorFinishedRef.v = true;
|
||||
}
|
||||
}
|
||||
|
||||
function old_assertNotFinished(decoratorFinishedRef, fnName) {
|
||||
if (decoratorFinishedRef.v) {
|
||||
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
||||
}
|
||||
}
|
||||
|
||||
function old_assertMetadataKey(key) {
|
||||
if (typeof key !== "symbol") {
|
||||
throw new TypeError("Metadata keys must be symbols, received: " + key);
|
||||
}
|
||||
}
|
||||
|
||||
function old_assertCallable(fn, hint) {
|
||||
if (typeof fn !== "function") {
|
||||
throw new TypeError(hint + " must be a function");
|
||||
}
|
||||
}
|
||||
|
||||
function old_assertValidReturnValue(kind, value) {
|
||||
var type = typeof value;
|
||||
|
||||
if (kind === 1) {
|
||||
if (type !== "object" || value === null) {
|
||||
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
||||
}
|
||||
|
||||
if (value.get !== undefined) {
|
||||
old_assertCallable(value.get, "accessor.get");
|
||||
}
|
||||
|
||||
if (value.set !== undefined) {
|
||||
old_assertCallable(value.set, "accessor.set");
|
||||
}
|
||||
|
||||
if (value.init !== undefined) {
|
||||
old_assertCallable(value.init, "accessor.init");
|
||||
}
|
||||
|
||||
if (value.initializer !== undefined) {
|
||||
old_assertCallable(value.initializer, "accessor.initializer");
|
||||
}
|
||||
} else if (type !== "function") {
|
||||
var hint;
|
||||
|
||||
if (kind === 0) {
|
||||
hint = "field";
|
||||
} else if (kind === 10) {
|
||||
@@ -240,25 +196,19 @@ function old_assertValidReturnValue(kind, value) {
|
||||
} else {
|
||||
hint = "method";
|
||||
}
|
||||
|
||||
throw new TypeError(hint + " decorators must return a function or void 0");
|
||||
}
|
||||
}
|
||||
|
||||
function old_getInit(desc) {
|
||||
var initializer;
|
||||
|
||||
if ((initializer = desc.init) == null && (initializer = desc.initializer) && typeof console !== "undefined") {
|
||||
console.warn(".initializer has been renamed to .init as of March 2022");
|
||||
}
|
||||
|
||||
return initializer;
|
||||
}
|
||||
|
||||
function old_applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, metadataMap, initializers) {
|
||||
var decs = decInfo[0];
|
||||
var desc, initializer, value;
|
||||
|
||||
if (isPrivate) {
|
||||
if (kind === 0 || kind === 1) {
|
||||
desc = {
|
||||
@@ -281,7 +231,6 @@ function old_applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate,
|
||||
} else if (kind !== 0) {
|
||||
desc = Object.getOwnPropertyDescriptor(base, name);
|
||||
}
|
||||
|
||||
if (kind === 1) {
|
||||
value = {
|
||||
get: desc.get,
|
||||
@@ -294,15 +243,11 @@ function old_applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate,
|
||||
} else if (kind === 4) {
|
||||
value = desc.set;
|
||||
}
|
||||
|
||||
var newValue, get, set;
|
||||
|
||||
if (typeof decs === "function") {
|
||||
newValue = old_memberDec(decs, name, desc, metadataMap, initializers, kind, isStatic, isPrivate, value);
|
||||
|
||||
if (newValue !== void 0) {
|
||||
old_assertValidReturnValue(kind, newValue);
|
||||
|
||||
if (kind === 0) {
|
||||
initializer = newValue;
|
||||
} else if (kind === 1) {
|
||||
@@ -321,11 +266,9 @@ function old_applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate,
|
||||
for (var i = decs.length - 1; i >= 0; i--) {
|
||||
var dec = decs[i];
|
||||
newValue = old_memberDec(dec, name, desc, metadataMap, initializers, kind, isStatic, isPrivate, value);
|
||||
|
||||
if (newValue !== void 0) {
|
||||
old_assertValidReturnValue(kind, newValue);
|
||||
var newInit;
|
||||
|
||||
if (kind === 0) {
|
||||
newInit = newValue;
|
||||
} else if (kind === 1) {
|
||||
@@ -339,7 +282,6 @@ function old_applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate,
|
||||
} else {
|
||||
value = newValue;
|
||||
}
|
||||
|
||||
if (newInit !== void 0) {
|
||||
if (initializer === void 0) {
|
||||
initializer = newInit;
|
||||
@@ -352,7 +294,6 @@ function old_applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (kind === 0 || kind === 1) {
|
||||
if (initializer === void 0) {
|
||||
initializer = function (instance, init) {
|
||||
@@ -360,27 +301,21 @@ function old_applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate,
|
||||
};
|
||||
} else if (typeof initializer !== "function") {
|
||||
var ownInitializers = initializer;
|
||||
|
||||
initializer = function (instance, init) {
|
||||
var value = init;
|
||||
|
||||
for (var i = 0; i < ownInitializers.length; i++) {
|
||||
value = ownInitializers[i].call(instance, value);
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
} else {
|
||||
var originalInitializer = initializer;
|
||||
|
||||
initializer = function (instance, init) {
|
||||
return originalInitializer.call(instance, init);
|
||||
};
|
||||
}
|
||||
|
||||
ret.push(initializer);
|
||||
}
|
||||
|
||||
if (kind !== 0) {
|
||||
if (kind === 1) {
|
||||
desc.get = value.get;
|
||||
@@ -392,7 +327,6 @@ function old_applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate,
|
||||
} else if (kind === 4) {
|
||||
desc.set = value;
|
||||
}
|
||||
|
||||
if (isPrivate) {
|
||||
if (kind === 1) {
|
||||
ret.push(function (instance, args) {
|
||||
@@ -413,15 +347,14 @@ function old_applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function old_applyMemberDecs(ret, Class, protoMetadataMap, staticMetadataMap, decInfos) {
|
||||
var protoInitializers;
|
||||
var staticInitializers;
|
||||
var existingProtoNonFields = new Map();
|
||||
var existingStaticNonFields = new Map();
|
||||
|
||||
for (var i = 0; i < decInfos.length; i++) {
|
||||
var decInfo = decInfos[i];
|
||||
|
||||
if (!Array.isArray(decInfo)) continue;
|
||||
var kind = decInfo[1];
|
||||
var name = decInfo[2];
|
||||
@@ -430,12 +363,10 @@ function old_applyMemberDecs(ret, Class, protoMetadataMap, staticMetadataMap, de
|
||||
var base;
|
||||
var metadataMap;
|
||||
var initializers;
|
||||
|
||||
if (isStatic) {
|
||||
base = Class;
|
||||
metadataMap = staticMetadataMap;
|
||||
kind = kind - 5;
|
||||
|
||||
if (kind !== 0) {
|
||||
staticInitializers = staticInitializers || [];
|
||||
initializers = staticInitializers;
|
||||
@@ -443,17 +374,14 @@ function old_applyMemberDecs(ret, Class, protoMetadataMap, staticMetadataMap, de
|
||||
} else {
|
||||
base = Class.prototype;
|
||||
metadataMap = protoMetadataMap;
|
||||
|
||||
if (kind !== 0) {
|
||||
protoInitializers = protoInitializers || [];
|
||||
initializers = protoInitializers;
|
||||
}
|
||||
}
|
||||
|
||||
if (kind !== 0 && !isPrivate) {
|
||||
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
||||
var existingKind = existingNonFields.get(name) || 0;
|
||||
|
||||
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
|
||||
throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
||||
} else if (!existingKind && kind > 2) {
|
||||
@@ -462,37 +390,30 @@ function old_applyMemberDecs(ret, Class, protoMetadataMap, staticMetadataMap, de
|
||||
existingNonFields.set(name, true);
|
||||
}
|
||||
}
|
||||
|
||||
old_applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, metadataMap, initializers);
|
||||
}
|
||||
|
||||
old_pushInitializers(ret, protoInitializers);
|
||||
old_pushInitializers(ret, staticInitializers);
|
||||
}
|
||||
|
||||
function old_pushInitializers(ret, initializers) {
|
||||
if (initializers) {
|
||||
ret.push(function (instance) {
|
||||
for (var i = 0; i < initializers.length; i++) {
|
||||
initializers[i].call(instance);
|
||||
}
|
||||
|
||||
return instance;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function old_applyClassDecs(ret, targetClass, metadataMap, classDecs) {
|
||||
if (classDecs.length > 0) {
|
||||
var initializers = [];
|
||||
var newClass = targetClass;
|
||||
var name = targetClass.name;
|
||||
|
||||
for (var i = classDecs.length - 1; i >= 0; i--) {
|
||||
var decoratorFinishedRef = {
|
||||
v: false
|
||||
};
|
||||
|
||||
try {
|
||||
var ctx = Object.assign({
|
||||
kind: "class",
|
||||
@@ -503,13 +424,11 @@ function old_applyClassDecs(ret, targetClass, metadataMap, classDecs) {
|
||||
} finally {
|
||||
decoratorFinishedRef.v = true;
|
||||
}
|
||||
|
||||
if (nextNewClass !== undefined) {
|
||||
old_assertValidReturnValue(10, nextNewClass);
|
||||
newClass = nextNewClass;
|
||||
}
|
||||
}
|
||||
|
||||
ret.push(newClass, function () {
|
||||
for (var i = 0; i < initializers.length; i++) {
|
||||
initializers[i].call(newClass);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user